Cradle
0.3.3
Simple library for creating Web-based applications
|
SQL request wrapper. More...
Static Public Member Functions | |
static | select ($query="", $data=null, $connection=null, $returnStatment=false) |
static | insert ($query, $data=null, $connection=null, $returnStatment=false) |
static | update ($query, $data=null, $connection=null, $returnStatment=false) |
static | delete ($query, $data=null, $connection=null, $returnStatment=false) |
static | getLastError () |
static | connect ($connection=null) |
Static Public Attributes | |
static | $default |
SQL request wrapper.
A simple SQL (PDO) request wrapper class. Designed to make simple SQL requests more easy and short.
Supported databse types: mysql, pgsql, oci, sqlite, dblib(mssql,sybase) ...and all of PDO db types. Use:
to see all avalible PDO db types.
|
static |
Initiates an SQL connection
array | $connection | An array of connection params: [
"type" => "mysql",
"host" => "hostname",
"base" => "database name",
"user" => "user login",
"pass" => "password",
"table"=> "default table name", //<-- option
];
|
|
static |
SQL DELETE request
string | $query | if $default["autoquery"]==true then:
1. delete from ...
2. from ...
3. ...
4. < empty >
tag [TABLE] - will be replaced by $connection['table']
else $query mast be standard sql-query: "delete from ... where ..."
|
array | $data | 1. $query="delete from ... where f1=?, f2=?, f3-?, ..." => $data = array(1, 2, 3 ...)
2. $query="delete from ... where f1=:f1 and f2=:f2 and f3=:f3, ..." => $data = array("f1"=>1, "f2"=>2, "f3"=>3 ...)
|
array | $connection | (option) An array of connection params (see a method connect) |
boolean | $returnStatment | [ true | false ] false - return rowCount true - return { PDOStatement } |
|
static |
Returns the last error of request
|
static |
SQL INSERT Request
String | $query | if $default["autoquery"]==true then:
1. insert into ...
2. into ...
3. ...
4. < empty >
tag [TABLE] - will be replaced by $connection['table']
else $query mast be standard sql-query: "insert into ... (...) values (...)"
|
array | $data | 1. $query="insert into ... (f1,f2,f3...) values (?,?,?,..)" => $data = array(1, 2, 3 ...)
2. $query="insert into ... (f1,f2,f3...) values (:f1,:f2,:f3,...)" => $data = array("f1"=>1, "f2"=>2, "f3"=>3 ...)
|
array | $connection | (option) An array of connection params (see a method connect) |
boolean | $returnStatment | [ true | false ] false - return rowCount true - return { PDOStatement } |
|
static |
SQL SELECT Request
string | $query | if $default["autoquery"]==true then:
1. select ...
2. ... from ...
3. from ...
4. where ...
5. < empty >
tag [TABLE] - will be replaced by $connection['table']
tag [WHERE] - will be replaced by auto created WHERE condition (if $data is array)
else $query mast be standard sql-query: "select ... from ... where ..."
|
array | $data | 1. $query="select ... where f1=? and f2=? and f3=?" => $data = array(1, 2, 3 ...)
2. $query="select ... where f1=:f1 and f2=:f2 and f3=:f3" => $data = array("f1"=>1, "f2"=>2, "f3"=>3 ...)
|
array | $connection | (option) An array of connection params (see a method connect) |
boolean | $returnStatment | [ true | false ] false - return array( 0=>array(fname=>value, ...), 1=... ); true - return { PDOStatement } |
|
static |
SQL UPDATE request
string | $query | if $default["autoquery"]==true then:
1. update ...
2. ...
4. < empty >
tag [TABLE] - will be replaced by $connection['table']
else $query mast be standard sql-query: "update ... set ... where ..."
|
array | $data | 1. $query="update ... set f1=?, f2=?, ... where f3=? and f4=?, ..." => $data = array(1, 2, 3, 4 ...)
2. $query="update ... " => $data = array( array("f1"=>1, "f2"=>2, ...), array("f3"=>3, "f4"=>4, ...) )
--- "set" data ------------- ----- "where" keys ---------
|
array | $connection | (option) An array of connection params (see a method connect) |
boolean | $returnStatment | [ true | false ] false - return rowCount true - return { PDOStatement } |
|
static |