Jump to content

Whats the difference?


immanuelx2

Recommended Posts

$count_query = mysql_query('SELECT COUNT(*) FROM table');
$getcount = mysql_fetch_row($count_query);
$count = $getcount['0'];

vs.

$count_query = mysql_query('SELECT * FROM table');
$count = mysql_num_rows($count_query);

and...

$query = mysql_query('SELECT * FROM table');
if (!$query) die(mysql_error());

vs.

$query = mysql_query('SELECT * FROM table') or die(mysql_error());

 

any differences between those scenarios?

Link to comment
https://forums.phpfreaks.com/topic/55801-whats-the-difference/
Share on other sites

$count_query = mysql_query('SELECT COUNT(*) FROM table');
$getcount = mysql_fetch_row($count_query);
$count = $getcount['0'];

vs.

$count_query = mysql_query('SELECT * FROM table');
$count = mysql_num_rows($count_query);

 

One record is loaded into memory vs all the records loaded into memory

 

$query = mysql_query('SELECT * FROM table');
if (!$query) die(mysql_error());

vs.

$query = mysql_query('SELECT * FROM table') or die(mysql_error())

 

not a great deal or difference - readability mostly.

Link to comment
https://forums.phpfreaks.com/topic/55801-whats-the-difference/#findComment-275729
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.