Created
July 13, 2012 19:45
-
-
Save bobmagicii/3106970 to your computer and use it in GitHub Desktop.
Using Database in Menagerie
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 | |
/* this is assuming we have a database configured in the config file under the | |
alias of 'default' - for this example we assume it is MySQL. */ | |
require('m/application.php'); | |
$db = new m/database; | |
$id = 42; | |
// when using the queryf method of the database library, all format arguments | |
// are automatically string escaped for you using the proper database escape | |
// function provided by the database driver. | |
$query = $db->queryf( | |
'SELECT * FROM test WHERE id=%d LIMIT 1;', | |
$id | |
); | |
while($row = $query->next()) { | |
var_dump($row); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment