SDb
extends Db
in package
Table of Contents
Properties
- $_allow_engines : mixed
- $_config_file : mixed
- $_engine_name : mixed
- $_fields : mixed
- 字段属性结构 $user->id=1; $user->name="XX"; $user->nickname="nickname"; $user->profile->address="my address"; $user->profile->comment="comment";
- $_key : mixed
- $count : mixed
- $engine : mixed
- $error : mixed
- $foreign_keys : mixed
- $limit : mixed
- $page : mixed
- $params : mixed
- $table_name : mixed
Methods
- __construct() : void
- 构造方法
- __get() : mixed
- __set() : mixed
- del() : mixed
- 删除信息,可以连带外键一起删除
- delete() : int|bool
- delete
- error() : mixed
- escape() : mixed
- execute() : bool|int|array<string|int, mixed>
- get() : mixed
- 得到信息,返回数组,可以用对像获取本身
- getAll() : mixed
- 得到带外键的信息
- getConfig() : array<string|int, mixed>
- init() : mixed
- insert() : int|bool
- insert
- listAll() : mixed
- reset() : mixed
- 重设所有参数
- select() : DbData
- select data from db
- selectOne() : mixed
- select one from select result
- set() : mixed
- 保存信息,支持外键属性保存 当外键属性保存时,特别注意: 你必须初始化外键的值,否则可能无效,如: $test->user_profile = new stdclass; $test->user_profile->field_name = "field_value";
- setConfig() : array<string|int, mixed>
- 设置数据库配置文件
- setConfigFile() : void
- set global db config file
- setCount() : mixed
- is count
- setForeignKey() : mixed
- 设置外键关联
- setLimit() : mixed
- page size
- setPage() : mixed
- page number
- setTable() : mixed
- update() : int|bool
- update data
- useConfig() : mixed
- __addsqlslashes() : mixed
- __array2string() : mixed
- __query() : array<string|int, mixed>
- query
- __quote() : mixed
- __setEngine() : mixed
- _reInit() : mixed
- construct
- merge_params() : mixed
- merge array
Properties
$_allow_engines
private
mixed
$_allow_engines
= array("mysqli", "pdo_mysql", "pdo_sqlite", "pdo_cubrid", "pdo_dblib", "pdo_firebird", "pdo_ibm", "pdo_informix", "pdo_sqlsrv", "pdo_oci", "pdo_odbc", "pdo_pgsql", "pdo_4d")
$_config_file
private
static mixed
$_config_file
$_engine_name
private
mixed
$_engine_name
= "pdo_mysql"
$_fields
字段属性结构 $user->id=1; $user->name="XX"; $user->nickname="nickname"; $user->profile->address="my address"; $user->profile->comment="comment";
private
mixed
$_fields
$_key
private
mixed
$_key
$count
private
mixed
$count
= true
$engine
private
mixed
$engine
$error
private
mixed
$error
= array('code' => 0, 'msg' => "")
$foreign_keys
private
mixed
$foreign_keys
= array()
$limit
private
mixed
$limit
= 0
$page
private
mixed
$page
= 1
$params
private
mixed
$params
$table_name
private
mixed
$table_name
= ""
Methods
__construct()
构造方法
public
__construct([string $table_name = "" ][, mixed $config = array() ]) : void
Parameters
- $table_name : string = ""
- $config : mixed = array()
__get()
public
__get(mixed $k) : mixed
Parameters
- $k : mixed
__set()
public
__set(mixed $k, mixed $v) : mixed
Parameters
- $k : mixed
- $v : mixed
del()
删除信息,可以连带外键一起删除
public
del([mixed $foreign_info = false ]) : mixed
Parameters
- $foreign_info : mixed = false
delete()
delete
public
delete(string|array<string|int, mixed>|object $table, string|array<string|int, mixed>|object $condition) : int|bool
Parameters
- $table : string|array<string|int, mixed>|object
- $condition : string|array<string|int, mixed>|object
Return values
int|boolerror()
public
error() : mixed
escape()
public
escape(mixed $str) : mixed
Parameters
- $str : mixed
execute()
public
execute(string $sql) : bool|int|array<string|int, mixed>
Parameters
- $sql : string
Return values
bool|int|array<string|int, mixed>get()
得到信息,返回数组,可以用对像获取本身
public
get([mixed $foreign_info = false ]) : mixed
Parameters
- $foreign_info : mixed = false
getAll()
得到带外键的信息
public
getAll() : mixed
getConfig()
public
static getConfig([string $zone = null ][, string $type = "main" ]) : array<string|int, mixed>
Parameters
- $zone : string = null
- $type : string = "main"
-
main|query
Return values
array<string|int, mixed>init()
public
init(mixed $params) : mixed
Parameters
- $params : mixed
insert()
insert
public
insert(string|array<string|int, mixed>|object $table[, string|array<string|int, mixed>|object $item = "" ][, bool $isreplace = false ][, bool $isdelayed = false ][, string|array<string|int, mixed>|object $update = array() ][, mixed $ignore = false ]) : int|bool
Parameters
- $table : string|array<string|int, mixed>|object
- $item : string|array<string|int, mixed>|object = ""
- $isreplace : bool = false
- $isdelayed : bool = false
- $update : string|array<string|int, mixed>|object = array()
- $ignore : mixed = false
Return values
int|bool —int(lastInsertId or affectedRows)
listAll()
public
listAll(mixed $condition[, mixed $foreign_info = false ]) : mixed
Parameters
- $condition : mixed
- $foreign_info : mixed = false
reset()
重设所有参数
public
reset() : mixed
select()
select data from db
public
select(string|array<string|int, mixed>|object $table[, string|array<string|int, mixed>|object $condition = "" ][, string|array<string|int, mixed>|object $item = "" ][, string|array<string|int, mixed>|object $groupby = "" ][, string|array<string|int, mixed>|object $orderby = "" ][, string|array<string|int, mixed>|object $leftjoin = "" ]) : DbData
Parameters
- $table : string|array<string|int, mixed>|object
- $condition : string|array<string|int, mixed>|object = ""
- $item : string|array<string|int, mixed>|object = ""
- $groupby : string|array<string|int, mixed>|object = ""
- $orderby : string|array<string|int, mixed>|object = ""
- $leftjoin : string|array<string|int, mixed>|object = ""
Return values
DbData —object || Boolean false
selectOne()
select one from select result
public
selectOne(mixed $table[, mixed $condition = "" ][, mixed $item = "" ][, mixed $groupby = "" ][, mixed $orderby = "" ][, mixed $leftjoin = "" ]) : mixed
Parameters
- $table : mixed
- $condition : mixed = ""
- $item : mixed = ""
- $groupby : mixed = ""
- $orderby : mixed = ""
- $leftjoin : mixed = ""
set()
保存信息,支持外键属性保存 当外键属性保存时,特别注意: 你必须初始化外键的值,否则可能无效,如: $test->user_profile = new stdclass; $test->user_profile->field_name = "field_value";
public
set() : mixed
setConfig()
设置数据库配置文件
public
setConfig(string $zone[, string $type = "main" ]) : array<string|int, mixed>
Parameters
- $zone : string
- $type : string = "main"
-
main|query
Return values
array<string|int, mixed>setConfigFile()
set global db config file
public
static setConfigFile(string $file) : void
Parameters
- $file : string
setCount()
is count
public
setCount(mixed $count) : mixed
Parameters
- $count : mixed
setForeignKey()
设置外键关联
public
setForeignKey([mixed $keys = array() ]) : mixed
Parameters
- $keys : mixed = array()
setLimit()
page size
public
setLimit(mixed $limit) : mixed
Parameters
- $limit : mixed
setPage()
page number
public
setPage(mixed $page) : mixed
Parameters
- $page : mixed
setTable()
public
setTable(mixed $table_name) : mixed
Parameters
- $table_name : mixed
update()
update data
public
update(string|array<string|int, mixed>|object $table, string|array<string|int, mixed>|object $condition, string|array<string|int, mixed>|object $item) : int|bool
Parameters
- $table : string|array<string|int, mixed>|object
- $condition : string|array<string|int, mixed>|object
- $item : string|array<string|int, mixed>|object
Return values
int|booluseConfig()
public
useConfig(mixed $zone[, mixed $type = "main" ]) : mixed
use setConfig
Parameters
- $zone : mixed
- $type : mixed = "main"
__addsqlslashes()
private
__addsqlslashes(mixed $k) : mixed
Parameters
- $k : mixed
__array2string()
private
__array2string(mixed $mixed[, mixed $alais = false ]) : mixed
Parameters
- $mixed : mixed
- $alais : mixed = false
__query()
query
private
__query(string $sql[, mixed $retry = false ][, mixed $params = [] ]) : array<string|int, mixed>
Parameters
- $sql : string
- $retry : mixed = false
- $params : mixed = []
Return values
array<string|int, mixed> —$result || Boolean false
__quote()
private
__quote(mixed $condition[, mixed $split = "AND" ][, mixed &$params = [] ]) : mixed
Parameters
- $condition : mixed
- $split : mixed = "AND"
- $params : mixed = []
__setEngine()
private
__setEngine(mixed $engineName) : mixed
Parameters
- $engineName : mixed
_reInit()
construct
private
_reInit() : mixed
merge_params()
merge array
private
merge_params(mixed ...$arr) : mixed
Parameters
- $arr : mixed