class DB()
=========================================
class DB()
=========================================
DB::select()
DB::Select(String $query)
Parameter:
String $query
DB::Select(Array $mixed)
DB::select([
query,
where,
var,
options,
connection,
]);
Parameter:
String $query
Array $where
Array $var
Array $options
Array | String $connection
Result
Property:
Int $count
Array $items
Parameter
where
%WHERE% in query statement
where => [
'%WHERE%' => [
[condition1, ":variable1" => value1],
[condition2, ":variable2" => value2],
]
]
var
var => [
'$variable' => value, // Value quote with '
'$variable$' => value, // Value not qoute
':variable' => value, // Value quote with '
':`variable`' => value, // Value is quote with `
':variable' => new DataModel()
':variable' => SetDataModel()
':variable' => JsonDataModel()
':variable' => JsonArrayDataModel()
]
options
options => [
"sum" => "fieldName1,fieldName2",
"group" => "fieldName",
"key" => "fieldName",
"value" => "fieldName",
"log" => boolean,
"history" => boolean,
"multiple" => boolean,
"debug" => boolean,
"jsonDecode" => [
['field' => 'fieldName', 'type' => 'merge,default']
...
],
]
Data Model
class DataModel()
class SetDataModel()
class JsonDataModel()
class JsonArrayDataModel()
====== END ======
Property :
public $class='mydb';
public static $version='3.10';
public $dburi;
private $server;
private $user;
private $password;
private $host;
public $db;
private $mydb;
public $status=false;
public $simulate=false;
public $_watchlog=true;
public $_query;
public $_affected_rows;
public $_error;
public $_error_no;
public $_errors=array();
public $_query_count=0;
public $_query_items=array();
public $_field=array();
public $_where=array();
public $_values=array();
private $multiquery=false;
Method :
mydb::Constructor ( $dburi )
mydb::where ( $condition , $key , $value [, $key , $value] )
mydb::query ( $stmt , $key , $value [, $key , $value] , $object , $array )
mydb::select ( $stmt , $key , $value [, $key , $value] , $object , $array )
mydb::clearProp ( $rs )
mydb::table_list ()
mydb::table_exists ( $table_name )
mydb::columns ( $table,$col_name, $dbname )
mydb::clear_autoid ( $table )
mydb::get_set_member ( $table_name, $col_name )
mydb::make_set ( $set_value=array() )
mydb::convert_record_to_recordset ( $rs )
mydb::create_insert_cmd ( $table_name, $values=array() )
mydb::create_update_cmd ( $table_name, $values=array(), $cond )
mydb::table_is_lock ( $table_name, $db_name )
mydb::printTable ( $dbs )
mydb::setMultiQuery ( $value )
Method description
mydb::Constructor ( $dburi )
array mydb::where ( string $condition [, string $key , mixed $value [,...]] )
array , object mydb::query ( $stmt , [, string $key , mixed $value [,...]] , $object , $array )
object mydb::select ( $stmt , [, string $key , mixed $value [,...]] , $object , $array )
object mydb::clearProp ( object $rs )
array mydb::table_list ()
bool mydb::table_exists ( string $table_name )
array , bool mydb::columns ( string $table , string $col_name, string $dbname )
int mydb::clear_autoid ( string $table )
string mydb::get_set_member ( string $table_name, string $col_name )
string mydb::make_set ( array $set_value )
object mydb::convert_record_to_recordset ( object $rs )
string mydb::create_insert_cmd ( string $table_name, array $values )
string mydb::create_update_cmd ( string $table_name, array $values, string $cond )
bool mydb::table_is_lock ( string $table_name, string $db_name )
string mydb::printTable ( object $dbs )
mydb::setMultiQuery ( bool $value )