I found a few entries that dealt directly with my problem but there were no solutions. I am hoping that somebody can provide me with an answer or a link to one. I've been searching all day.
Here is a snippet:
$a->start();
if ($a->checkAuth()) {
$res =& $mdb2->query('SELECT * FROM perm WHERE username = '.$a->getUsername().'');
$auth = $res->fetchRow();
if (PEAR::isError($res)) {
die($res->getMessage());
}
} else {
$auth['level'] = 'guest';
}
Desired end result is an array $auth['username'], $auth['level'] and so on for just the user selected in the database.
Now, I can get this to work by doing:
$a->start();
if ($a->checkAuth()) {
$res =& $mdb2->query('SELECT * FROM perm');
while ($row = $res->fetchRow()) {
if ($row['username'] == $a->getUsername()) {
$auth = $row;
}
}
if (PEAR::isError($res)) {
die($res->getMessage());
}
} else {
$auth['level'] = 'guest';
}
... but I'm sure we can see the problem here, very inefficient if the table gets big to take an array of every row and column just to get the one. When I run the top version with no while and a 'WHERE' clause I get this error.
Fatal error: Call to undefined method MDB2_Error::fetchRow() in /home/kansasre/public_html/assets/integral.php on line 77
Why? I'm guessing it has something to do with the result pointer, but I don't care. I just need a way to query one row and get that row's data in an associative array.
Please help.