"OO"oo the troubles [SOLVED]
Posted: Sun May 27, 2007 3:40 pm
I'm writing a mysql wrapper class, and I'm having troubles understanding the return values of mysql_query();
The manual says this:
var_dump($result) is returning (bool) true. Where's that coming from?
I get the following errors:
Excerpt from my wrapper class
What I can think of is that return cannot return a resource, and instead I should set a $result_resource array in the class properties?
Edit: I should note that $db->query returns (bool) true, regardless if the query returns a result or not.
The manual says this:
So, this is my coding:For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
Code: Select all
$blog_id = $db->escape(htmlentities(stripslashes($_GET['blog_id']), ENT_QUOTES));
$result = $db->query("SELECT * FROM `blogs` WHERE `id` = '85' LIMIT 1");
var_dump($result);
echo $db->num_rows($result);
if($db->num_rows($result))
{
//continue...
}I get the following errors:
Code: Select all
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Apache2\htdocs\class\mysql.class.php on line 49Code: Select all
/*
* Performs a query on the database and returns the result set
* @param str $sql
*/
function query($sql)
{
return mysql_query($sql, $this->link_id) or die(mysql_error());
}
/*
* Gathers and returns the number of rows from a result set
* @param resource $result
*/
function num_rows($result)
{
return mysql_num_rows($result);
}Edit: I should note that $db->query returns (bool) true, regardless if the query returns a result or not.