Skip to content

Instantly share code, notes, and snippets.

@bobmagicii
Created July 13, 2012 19:45
Show Gist options
  • Save bobmagicii/3106970 to your computer and use it in GitHub Desktop.
Save bobmagicii/3106970 to your computer and use it in GitHub Desktop.
Using Database in Menagerie
<?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