Join us at IRC!
The measure of a mans life is not how well he dies, but how well he lives.
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 36
Web Spiders: 14
Guests Online: 29
Members Online: 7

Registered Members: 70203
Newest Member: monkiman
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Page 3 of 3 < 1 2 3
Author

RE: mysql/php

c4p_sl0ck
Member



Posts: 380
Location: Sweden‮‭
Joined: 17.09.06
Rank:
God
Posted on 25-07-09 01:39
system_meltdown wrote:
Alternatively, create a your own MySQL class.


Or if you don't have time, knowledge or don't feel like it, you can use the MySQLi class instead of making your own.



c4p_sl0ck@hotmail.com
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 01:57
c4p_sl0ck wrote:
system_meltdown wrote:
Alternatively, create a your own MySQL class.


Or if you don't have time, knowledge or don't feel like it, you can use the MySQLi class instead of making your own.


Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.




http://www.elites0ft.com/
Author

RE: mysql/php

p4plus2
Member

Posts: 167
Location:
Joined: 31.03.08
Rank:
God
Posted on 25-07-09 02:18
system_meltdown wrote:

Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.


I agree with you for the most part, however if you are after speed use MySQLi. Writing your own class can in some cases be up to three times slower than procedural programming styles. Classes still become useful when it comes to flexibility, code organization, and reusability.

For anybody that wants a decent comparison of OOP and procedural programming check out this link.
http://devzone.zend.com/article/1236



"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 10:47
p4plus2 wrote:
system_meltdown wrote:

Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.


I agree with you for the most part, however if you are after speed use MySQLi. Writing your own class can in some cases be up to three times slower than procedural programming styles. Classes still become useful when it comes to flexibility, code organization, and reusability.

For anybody that wants a decent comparison of OOP and procedural programming check out this link.
http://devzone.zend.com/article/1236


Agreed, over-use of OOP when it's not needed just uses up resources. However I'm guessing since this guy seems pretty new to PHP, he won't care for code optimization, so writing his own class would be fine (if he thinks he can do it at least), else, go with MySQLi, it's pretty slick.




http://www.elites0ft.com/
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Hacker Level 1
Posted on 25-07-09 10:53
system_meltdown wrote:
Agreed, over-use of OOP when it's not needed just uses up resources. However I'm guessing since this guy seems pretty new to PHP, he won't care for code optimization, so writing his own class would be fine (if he thinks he can do it at least), else, go with MySQLi, it's pretty slick.


nice discussion there =D that's why I like asking questions instead of googling =D=D

The time / knowledge is not the issue here, I can spend a couple hours learning more about php, but to be honest I don't care that much about the optimization or the method itself as long as it gets the job done in the way it's suppose to. Although I gotta say that I find OOP overkill for this particular task! A config file would do just fine I guess =D





Edited by Demons Halo on 25-07-09 10:56
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

c4p_sl0ck
Member



Posts: 380
Location: Sweden‮‭
Joined: 17.09.06
Rank:
God
Posted on 25-07-09 16:21
MoshBat wrote:
require_once("config.php");

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.



c4p_sl0ck@hotmail.com
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 17:28
c4p_sl0ck wrote:
MoshBat wrote:
require_once("config.php";);

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.


Heh, require_once is like echo and print in the sense that both:

echo "hax";
and
echo( "hax" );

are the same.

So yeah, it's not "correct syntax"; however neglecting the brackets looks nicer in my opinion.




http://www.elites0ft.com/
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 18:22
MoshBat wrote:
Once again, it's a personal choice thing.


Yep, I don't like using too many brackets and braces, and I like to tab and space everything, makes it easier to read in my opinion.




http://www.elites0ft.com/
Author

RE: mysql/php

spyware
Member



Posts: 4190
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 25-07-09 18:45
MoshBat wrote:
which saves on mere bytes


You should compare compiled/processed code.




"The chowner of property." - Zeph
“Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.”
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
http://bitsofspy.net
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 20:54
MoshBat wrote:
system_meltdown wrote:
MoshBat wrote:
Once again, it's a personal choice thing.


Yep, I don't like using too many brackets and braces, and I like to tab and space everything, makes it easier to read in my opinion.

I like brackets, I like having everything compressed, such as
if($var == $lul){
print "Niiice";
}else{
print "Awwh, fuck";
}

which saves on mere bytes, and --to me-- just looks neater and more uniformed.
But I do, of course, indent appropriately.


echo is better to use than print :p

I dislike using: if( $blah == $blah ){

I find it makes the braces harder to match up, so much easier with them on a separate line :p




http://www.elites0ft.com/
Author

RE: mysql/php

p4plus2
Member

Posts: 167
Location:
Joined: 31.03.08
Rank:
God
Posted on 25-07-09 21:06
My personal style is adapted from the coding guidelines for the linux kernel.


<?php

function syntax()
{

$tab_width = 8;
$reason = 'legibility and lines stand out'

if($tab_width == 8){
echo $reason;
echo 'Line should also be kept under 80 characters when possible, however
I do tend to violate this rule on occasion.';
}else{
die('invalid tab width');
}
}

?>


function braces get there own lines, conditionals do not. It helps me determine what brace you are editing a bit faster IMO. In the linux kernel they tend to use no braces when possible, but I don't do this in php.


"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 25-07-09 21:39
MoshBat wrote:
Also, milliseconds don't matter to me in terms on print/echo.
We've been over this.
I probably use print because of my use of Perl.


It's not just that. Due to echo's nature, it can be overloaded, so instead you can use

echo "Hello, ", $_SESSION['username'], ", how are you?";


Which is a shit lot faster than concatenating with dots, something you cannot do with print.

Plus, if you like to save precious bytes, you should use echo as it's one char less than print :p




http://www.elites0ft.com/
Author

RE: mysql/php

c4p_sl0ck
Member



Posts: 380
Location: Sweden‮‭
Joined: 17.09.06
Rank:
God
Posted on 26-07-09 06:12
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
require_once("config.php");

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.

http://us3.php.net/manual/en/function.require-once.php
Nice try.
It's the other way round.
Most functions are intended to have brackets around them.
Quick demonstrative example:
require_once($Fuck);
require_once $fuck;


Actually, it's not. As you are referred to on the require_once page:
http://us3.php.net/manual/en/function.include-once.php
There they have this example:
<?php
include_once "a.php"; // this will include a.php
include_once "A.php"; // this will include a.php again! (PHP 4 only)
?>




c4p_sl0ck@hotmail.com
Author

RE: mysql/php

p4plus2
Member

Posts: 167
Location:
Joined: 31.03.08
Rank:
God
Posted on 26-07-09 06:56
c4p_sl0ck wrote:
Actually, it's not. As you are referred to on the require_once page:
http://us3.php.net/manual/en/function.include-once.php
There they have this example:
<?php
include_once "a.php"; // this will include a.php
include_once "A.php"; // this will include a.php again! (PHP 4 only)
?>



Also watch out for this:
<?php
var_dump(include_once "nonexistant.php"); // this will dump false
var_dump(include_once "nonexistant.php"); // this will dump true
?>


This happens because php thinks the file was already included, but as we know that is not the case. Not that this should really ever happen in the real world but I figured its worth pointing out.


"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php

c4p_sl0ck
Member



Posts: 380
Location: Sweden‮‭
Joined: 17.09.06
Rank:
God
Posted on 26-07-09 10:29
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?



c4p_sl0ck@hotmail.com
Author

RE: mysql/php

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 27-07-09 16:51
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?

Oh, nevermind.


Thats right. Give up mosh, just give up. :p


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Author

RE: mysql/php

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 27-07-09 21:56
MoshBat wrote:
S1L3NTKn1GhT wrote:
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?

Oh, nevermind.


Thats right. Give up mosh, just give up. :p

Gave up explaining.


Exactly. ;)


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Page 3 of 3 < 1 2 3
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.