Rand is how I judge when to use cron, I use
<?php
if((rand(0, 200)) == 1) {
// run cron
}
?>
Of course, once I launch Flyxa I will set the 200 higher, and as it gets more popular etc.

Rand is how I judge when to use cron, I use
<?php
if((rand(0, 200)) == 1) {
// run cron
}
?>
Of course, once I launch Flyxa I will set the 200 higher, and as it gets more popular etc.
How could this hapen to meeeeeeeeeeeeeee?lol.
Both are proper ways. And both end up with the same result, it's just select count() is faster.It would return the same error message doing it either as:
orPHP Code:if(mysql_num_rows($result)==0) { }
mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.PHP Code:$result = mysql_num_rows($query);
if($result==0) { }
Personally I prefer to use:
It is just the same as putting it into a class and executing it:PHP Code:if(mysql_num_rows($result)==0) { }
However the proper way in which to return the amount of rows is by doing it in the SQL itself:PHP Code:if($db->num_rows($query)==0) { }
select count(id) as total from tablename where 1=1
also @ jack, this is faster than yours if you insist on using mysql_num_rows:
PHP Code:<?php
$knownSinner = mysql_query("SELECT * FROM `idiotlist` WHERE `username` = 'knownSinner'");
$Howmany = mysql_num_rows($knownSinner);
if ($Howmany === 0)
{
echo( 'You are only lying to yourself...' );
}
else
{
echo( 'That\'s what i thought.' );
}
?>
visit my internet web site on the internet
http://dong.engineer/
it is just videos by bill wurtz videos you have been warned
Ok thanksIt would return the same error message doing it either as:
orPHP Code:if(mysql_num_rows($result)==0) { }
mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.PHP Code:$result = mysql_num_rows($query);
if($result==0) { }
Personally I prefer to use:
It is just the same as putting it into a class and executing it:PHP Code:if(mysql_num_rows($result)==0) { }
However the proper way in which to return the amount of rows is by doing it in the SQL itself:PHP Code:if($db->num_rows($query)==0) { }
select count(id) as total from tablename where 1=1
Sorry, i got used to doing mysql_num_rows, please explain why thats fasterBoth are proper ways. And both end up with the same result, it's just select count() is faster.
also @ jack, this is faster than yours if you insist on using mysql_num_rows:
PHP Code:<?php
$knownSinner = mysql_query("SELECT * FROM `idiotlist` WHERE `username` = 'knownSinner'");
$Howmany = mysql_num_rows($knownSinner);
if ($Howmany === 0)
{
echo( 'You are only lying to yourself...' );
}
else
{
echo( 'That\'s what i thought.' );
}
?>![]()
Doing a query then counting the rows is slower than just doing a query to return the count of the rows.
=== is faster than == when it's the right situation to use it, and ' is faster than ", use " when you need interpreted stuff (i.e: \n \t) else don't use it atall.
Last edited by Jewish Bear; 07-05-2008 at 03:50 PM.
visit my internet web site on the internet
http://dong.engineer/
it is just videos by bill wurtz videos you have been warned
Ahh i never knew that, this thread is helping me learn things, cheers.
Want to hide these adverts? Register an account for free!