Thread: The SQL Class
View Single Post
Old 01-17-2009, 10:30 PM   #62 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

So let me get this straight with an example. Basically we'll connect to the database and return some results:
PHP Code:
$db = new DBmysql;
$db->setHandler('localhost''root''mysupersecretpassword''phlox_dev')
   ->
connect()
   ->
select();

$sql  'SELECT * FROM sample'// Assume columns: id, title

// Get associative array of rows
$rows $db->getFetch(truetrue$sql);
// or $rows = $db->exeQuery($sql)->loadFetch(true)->getFetch();
// or $rwos = $db->loadQuery($sql)->exeQuery()->getFetch(true, true);
// or $rows = $db->loadFetch(true, $sql)->getFetch();

foreach ($rows as $row)
{
    
sprintf("Yay I got record ID: %d\n"$row['id']);

Salathe is offline  
Reply With Quote