-
getId() : void
-
getType() : void
-
getClient() : void
-
getDriverName() : void
-
Instantiate pdo connection.
-
Get the id value.
-
Get a date time object.
-
Find one row that match criteria.
-
Find all records that match criteria.
-
Count rows that match criteria.
-
Prepare SQL WHERE condition.
-
SELECT record(s) that match criteria.
-
INSERT record into table.
-
UPDATE records in the table.
-
Remove records from the table.
-
Query sql statement. execute the statement and populate into Model object:
-
getLastInsertId() : intGet last inserted ID.
-
getError() : voidGet an error message.
-
public function getId()
-
public function getType()
-
public function getClient()
-
public function getDriverName()
-
public function __construct(string $dsn, string $user, string $password, array $options)
Instantiate pdo connection. -
public function getIdValue(variable $id)
Get the id value. -
public function getDateTime(variable $value, variable $model)
Get a date time object. -
public function findOne(string $from, variable $filters, array $options, array $fields)
Find one row that match criteria.//SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc Limit 1 $db->findOne("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"]], ["x","y"]);
-
public function find(string $from, variable $filters, array $options, array $fields)
Find all records that match criteria.//SELECT FROM users WHERE a=1 and b="q" $db->find("users", ["a" => 1, "b" => "q"]); //SELECT FROM users WHERE age>33 $db->find("users", ["age" => [">" => 33]]); //SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc $db->find("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"]], ["x","y"]);
-
public function count(string $from, variable $filters)
Count rows that match criteria.//SELECT count() as total FROM users WHERE a=1 $db->count("users", ["a" => 1]);
-
protected function where(variable $filters, array $values, array $options)
Prepare SQL WHERE condition. -
public function select(string $from, variable $filters, array $options, array $fields)
SELECT record(s) that match criteria.// MySQL: SELECT FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc LIMIT 10 // MSSQL: SELECT TOP 10 FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc $db->select("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"], "limit" => 10]); // MySQL: SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc LIMIT 10 offset 50 // MSSQL: SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc offset 50 ROWS FETCH NEXT 10 ROWS ONLY $db->select("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"], "limit" => 10, "offset" => 50], ["x","y"]);
-
public function insert(string $from, array $fields)
INSERT record into table.//INSERT INTO users (a,b) VALUES (1, 2) $db->insert("users", [["a" => 1], ["b" => 2]]);
-
public function update(string $from, variable $filters, array $fields)
UPDATE records in the table.//UPDATE users SET a=1, b=2 WHERE id=10 OR foo="bar" $db->update("users", ["OR" => ["id" => 10, "foo" => "bar"]], [["a" => 1], ["b" => 2]]);
-
public function delete(string $from, variable $filters)
Remove records from the table.//DELETE FROM users WHERE id=10 OR foo="bar" $db->delete("users", ["OR" => ["id" => 10, "foo" => "bar"]]);
-
public function query(string $sql, array $values, variable $obj)
Query sql statement. execute the statement and populate into Model object://select from t where id=1 $m = $this->db->query('select from t where id=:id', [':id' => 1], new stdClass); //select from t where id=1 OR foo='bar' $m = $this->db->query('select from t where id=? OR foo=?', [1, "bar"], '\Ice\Arr');
-
public function getLastInsertId()
Get last inserted ID. -
public function getError()
Get an error message.