Copyright 2013, Markus Hedlund [email protected], Snowfire AB, snowfire.net Licensed under the MIT License. Redistributions of files must retain the above copyright notice.
$database = new Snowfire\Database(array(
'user' => 'user name',
'pass' => 'password',
'dbname' => 'database name'
));
Default options are:
array(
'host' => '127.0.0.1',
'port' => 3306
)
For INSERT
, UPDATE
and DELETE
.
public function execute($sql, $parameters = array());
$database->execute('DELETE FROM table');
$database->execute('DELETE FROM table WHERE id = ?', $id);
$database->execute('DELETE FROM table WHERE id = ? OR id = ?', array($id1, $id2));
$database->execute('DELETE FROM table WHERE id = :current_id OR id = :master_id', array(
'current_id' => '1',
'master_id' => '2'
));
For SELECT
. Database::one()
returns the first row, Database::many()
returns an array with all rows.
public function one($sql, $parameters = array(), $option = null)
public function many($sql, $parameters = array(), $option = null)
Parameters $sql
and $parameters
works the same as in Database::execute()
.
single_column
, return only the first column for every row.
Returns the ID of the last inserted row.
Begin and end transactions with Database::transaction_begin()
and Database::transaction_end()
.