Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    sql array results

    I've only been able to get this to show one game from the database, but I like it to display 5 games, I've tried "while" statement and yet that comes back false

    limit = 5 (I want to show 5 results) this code is outputting only 1 result.

    PHP Code:
    $sql "SELECT * FROM games_info LIMIT 5";
    $runSql $dbBroker->arcade->fetchAll($sql);
            
        foreach(
    $runSql as $game)
        {
            
    print_r($game);echo "<br />";
        } 
    Thanks for anyone that can help me get the array function to work properly.
    Last edited by sitNsmile; 03-29-2010 at 08:34 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Could you please post the function fetchAll()?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by abduraooft View Post
    Could you please post the function fetchAll()?

    Right now i've got (includes built in APC cache)


    PHP Code:

    public function fetchAll($query,$ttl 0,$resultmode null){
            
            if(
    $ttl 0){
                
                
    $key md5($query);
                if(!
    $result apc_fetch($key)){
                    
    $result parent::query($query,$resultmode)->fetch_object();
                    
    apc_store($key,$result,$ttl);
                }
                
                return 
    $result;
            }
            
            
    //return parent::query($query,$resultmode)->fetch_object();
            
    if($return parent::query($query,$resultmode)){
             return 
    $return->fetch_object();
            }else{
             return array();
            }
        
        } 

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    FetchAll's job appears to be to fetch each of the columns, not the rows.
    MySQLi has a builtin method called fetch_all. If you use that one, $resultmode will have to be given a valid default. That will take more memory though compared to the while fetch. The end result should be about the same memory usage.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Yeah thanks, actually deceided to build another function to handle with the array method.

    PHP Code:
     private function _buildArray(mysqli_result $result
    so far things have come along okay.

    Thanks for input!


  •  

    Posting Permissions

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