-
Book Overview & Buying
-
Table Of Contents
concrete5 Cookbook
By :
Once you have loaded the database object, you can perform queries against it. In this recipe, we will select the contents of the Users table, and echo out each username.
Make sure you understand how to write database queries with SQL before diving into writing queries by hand in concrete5. There are dozens of MySQL resources available online and in print that go far beyond the scope of this book!
Have a look at the following steps:
Load the database object:
$db = Loader::db();
Write the query to select from the Users table:
$query = 'SELECT * FROM Users';
Execute the query:
$results = $db->getAll($query);
Loop through the results and echo each user's username:
foreach ($results as $user) {
echo $user['uName'].'<br />';
}
exit;This function works as you'd expect, but it takes a little of the tedium out of performing raw database queries with PHP and MySQL. Calling getAll function on the database object returns...
Change the font size
Change margin width
Change background colour