Page 5 of 5 FirstFirst 12345
Results 41 to 45 of 45
  1. #41
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    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.

  2. #42
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Baving View Post
    It would return the same error message doing it either as:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    or

    PHP Code:
     $result mysql_num_rows($query);
    if(
    $result==0) { } 
    mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.

    Personally I prefer to use:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    It is just the same as putting it into a class and executing it:

    PHP Code:
     if($db->num_rows($query)==0) { } 
    However the proper way in which to return the amount of rows is by doing it in the SQL itself:

    select count(id) as total from tablename where 1=1
    Both 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.' );
    }
    ?>


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #43
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Baving View Post
    It would return the same error message doing it either as:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    or

    PHP Code:
     $result mysql_num_rows($query);
    if(
    $result==0) { } 
    mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.

    Personally I prefer to use:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    It is just the same as putting it into a class and executing it:

    PHP Code:
     if($db->num_rows($query)==0) { } 
    However the proper way in which to return the amount of rows is by doing it in the SQL itself:

    select count(id) as total from tablename where 1=1
    Ok thanks




    Quote Originally Posted by Jewish Bear View Post
    Both 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.' );
    }
    ?>
    Sorry, i got used to doing mysql_num_rows, please explain why thats faster

  4. #44
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    Ok thanks






    Sorry, i got used to doing mysql_num_rows, please explain why thats faster
    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

  5. #45
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    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.
    Ahh i never knew that, this thread is helping me learn things, cheers.

Page 5 of 5 FirstFirst 12345

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •