Created
December 14, 2009 12:50
-
-
Save viccherubini/256027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Artisan/Db.php'; | |
require_once 'Artisan/Exception.php'; | |
$db_config = array( | |
'server' => 'localhost', | |
'username' => 'username', | |
'password' => 'password', | |
'database' => 'dbname' | |
); | |
$db = new Artisan_Db($db_config); | |
try { | |
$db->connect(); | |
$some_id = 10; | |
$sql = "SELECT * FROM `some_table` st WHERE st.id = '" . $some_id . "'"; | |
$db_result = $db->query($sql); | |
if ( $db_result->numRows() == 0 ) { | |
echo 'No rows returned!'; | |
} else { | |
while ( $row = $db_result->fetch() ) { | |
// $row is a key/value array of each row matched | |
} | |
} | |
$db->disconnect(); | |
} catch ( Artisan_Exception $e ) { | |
exit('An error occurred: ' . $e->getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment