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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
$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 07:06 PM..
Reason: I still cannot get it to budge
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
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
$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();
}
$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();
}
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php