Hi all!
I'm beginning to think I must be mentally disturbed 😉
Case:
Using a self made DB class, I want to get the query result sent back from this class and perform the classic while($row = mysql_fetch_object($myClass->getDataset()) on it.
But it always turns me back : "mysql_fetch_object : supplied argument is not a valid result resource". Indeed, the class seems to turn back #3 instead of the resource reference [#3].
All other operations I provide in the class work fine: adding, deleting, modifying records, and even getting a single record turned back (but in the latter case I do not need a dataset to be turned back from the class)
Can anyone help me out on this?
Code follows:
---------- Class snippet -----------
var $numresult;
var $dataset;
// user vars
var $username;
var $password;
var $email;
// Set methods
function setDataset($result) {$this->dataset = $result;}
// Get methods
function getDataset() {return $this->dataset;}
// Get all users for table given in parameter $tablename
function getUsers($tablename = "uploaders")
{
$this->setTablename($tablename);
$SQL = "select Usr, Pwd, Email from $this->tablename";
$result = mysql_query($SQL, $this->myConn) or QueryError($SQL);
$this->setDataset($result);
mysql_free_result($result);
}
---------- Calling code snippet -----------
$myClass = new theClass;
$myClass->getUsers();
while ($row=$myClass->getDataset()) { // Here is where it hurts :mad:
}
....