Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Just show me a simple query!

posted by dwaineh 10 years ago

I seem to be pretty dense I keep reading fResult, but all I get is errors..... I tried this:

$result = $db->query("SELECT * FROM guestbook");
 
foreach ($result as $row) {
    echo $row['name'] . '<br />';
}

and as close as I can get to a result is: Fatal error: Call to a member function query() on a non-object in P:
www
wms3
index.php on line 13

after hours of trying I got fDatabase and fSchema to work, I just rying simple steps to learn and it's not sinking in....

Your code looks great, but from the error message it seems that you are not creating a database object to query with. You'll need to add something like this to create the database object:

$db = new fDatabase('mysql', 'my_db', 'my_username', 'my_pass');

// Then you call $db->query() and loop through the result
posted by wbond 10 years ago

I had that included in my init.php, and it wasn't working, but I just re-tried it and it seems to work now, strange.... Well on to the next adventure and hopefully this starts flourish to be the base for my apps.

Thanks Will...

posted by dwaineh 10 years ago

I was having a similar problem. Seems the fix was just defining the DB type in the query. Example:

(note the $mysql_db-> that you didn't have)

$result = $mysql_db->query('SELECT * FROM users LIMIT 5');

posted by anonymous 8 years ago