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.
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    New Coder
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    We also use this for what is shown above:


    var $function = array(
    'connect' => 'mysql_connect',
    'select_db' => 'mysql_select_db',
    'query' => 'mysql_query',
    'num_rows' => 'mysql_num_rows',
    'close' => 'mysql_close',
    'fetch_array' => 'mysql_fetch_array',
    'escape' => 'mysql_real_escape_string'
    );

  2. #17
    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
    Resource id #x indicates that you've successfully acquired a resource in PHP. As pointed out, that means that the SQL did return a result. Use a command line client or something like phpMyAdmin to execute queries directly so see the results.
    In PHP world, you now have a resource in which you can operate on. The resource by itself is useless; you cannot print out a resource and expect anything meaningful off of it. You need to issue a fetch command to it to actually retrieve the data. Since you are using a custom class, we cannot provide you information on the fetching itself. Using just mysqli library directly, you'd have:
    PHP Code:
    $sQry =  "SELECT parent, MAX(`timestamp`) AS maxTimestamp FROM " PREFIX "replies WHERE type = 'ticket' GROUP BY parent";
    if (
    $qry $mysqliObj->query($sQry))
    {
        while (
    $aRecord $qry->fetch_assoc())
        {
            
    printf("Max timestamp for parent %s is %s" PHP_EOL$aRecord['parent'], $aRecord['maxTimestamp']);
        }
        
    $qry->free();

    Edit:
    Actually, with this list above you may be able to call the method fetch_array on the db object. That's a bad way of injecting functionality into it though.
    Last edited by Fou-Lu; 02-27-2013 at 06:37 PM.
    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 ;)

  3. Users who have thanked Fou-Lu for this post:

    fondy98 (02-27-2013)

  4. #18
    New Coder
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    This is some of the code:

    $replied = $site->db->query("SELECT parent, MAX(`timestamp`) AS maxTimestamp FROM " . PREFIX . "replies WHERE type = 'ticket' GROUP BY parent");
    if ($qry = $mysqliObj->query($sQry))
    {
    while ($aRecord = $qry->fetch_assoc())
    {
    printf("Max timestamp for parent %s is %s" . PHP_EOL, $aRecord['parent'], $aRecord['maxTimestamp']);
    }
    $qry->free();
    }
    Last edited by fondy98; 02-27-2013 at 08:06 PM. Reason: I still cannot get it to budge

  5. #19
    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
    You can't just copy and paste the mysqli usage. That was done as an example. You need to figure out how to make it work with your custom $site->db object.
    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 ;)

  6. Users who have thanked Fou-Lu for this post:

    fondy98 (02-27-2013)

  7. #20
    New Coder
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Oops, I did try and replace most of it, but still no go. That one above was accidentally the original mysqli usage. By the way, I don't think that mysqli will work as we are only on mySQL

  8. #21
    New Coder
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    $replied = $site->db->query("SELECT parent, MAX(`timestamp`) AS maxTimestamp FROM " . PREFIX . "replies WHERE type = 'ticket' GROUP BY parent");
    if ($replied = $site->db->query($sQry))
    {
    while ($ticket = $replied->fetch_assoc())
    {
    printf("Max timestamp for parent %s is %s" . PHP_EOL, $ticket['parent'], $ticket['maxTimestamp']);
    }
    $replied->free();
    }

    I tried this as well

  9. #22
    New Coder
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    $replied = $site->db->query("SELECT parent, MAX(`timestamp`) AS maxTimestamp FROM " . PREFIX . "replies WHERE type = 'ticket' GROUP BY parent");
    if ($replied = $site->db->query($sQry))
    {
    while ($replies = $replied->fetch_assoc())
    {
    printf("Max timestamp for parent %s is %s" . PHP_EOL, $replies['parent'], $replies['maxTimestamp']);
    }
    $replied->free();
    }

    ANd I tried this too

  10. #23
    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
    MySQLi is the replacement for MySQL. Since the mysql library will disappear in the future, the mysqli is there to replace it.
    Still isn't correct. $sQry doesn't exist anywhere here, so $replied will be set without a resource.
    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 ;)

  11. Users who have thanked Fou-Lu for this post:

    fondy98 (02-27-2013)


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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