helper.php
对数据库操作的封装 https://medoo.in/api/where
Table of Contents
Classes
- pg_pager_html
- <code> 类似淘宝分页
Functions
- pg_active_main() : mixed
- 激活平台数据库连接,平台数据库不支持从库读
- pg_active_read() : mixed
- 激活读数据库连接
- pg_active_default() : mixed
- 激活默认数据库连接
- pg_active() : mixed
- 激活当前使用哪个数据库
- get_pg_active_name() : mixed
- 获取当前启用的数据库连接
- pg_can_run_action() : mixed
- 判断是否可运行action
- pg_can_run_update() : mixed
- 数据库是否可执行更新操作
- new_pg() : mixed
- 连接数据库
- medoo_pg() : object
- 数据库实例
- pg() : mixed
- pg_pager() : mixed
- pg_pager_count() : mixed
- 设置分页总记录数 一般情况用不到
- pg_pager_html() : mixed
- 显示分页 调用pg_pager后,再调用。 pg_pager_html([ 'url'=>'', ]);
- pg_add_error() : mixed
- 添加错误信息
- pg_get_error() : mixed
- 获取错误信息
- pg_get() : mixed
- _pg_get() : mixed
- pg_select() : mixed
- $lists = pg_select('do_order', [ 'count' => 'COUNT(`id`)', 'total' => 'SUM(`total_fee`)', 'date' => "FROM_UNIXTIME(`inserttime`, '%Y-%m-%d')" ], 'WHERE `status` = 1 GROUP BY `date` LIMIT 30' );
- pg_insert() : array<string|int, mixed>
- 写入记录
- pg_update() : array<string|int, mixed>
- 更新记录
- pg_action() : mixed
- 数据库事务
- pg_for_update() : mixed
- 对数据进行
- pg_get_one() : array<string|int, mixed>
- 根据表名、字段 、条件 查寻一条记录
- pg_query() : mixed
- SQL查寻
- pg_get_min() : void
- 取最小值 https://medoo.in/api/min min($table, $column, $where) min($table, $join, $column, $where)
- pg_get_max() : void
- 取最大值 max($table, $column, $where) max($table, $join, $column, $where)
- pg_get_count() : void
- 总数 count($table, $where) count($table, $join, $column, $where)
- pg_get_has() : void
- 是否有记录 has($table, $where) has($table, $join, $where)
- pg_get_rand() : void
- 随机取多条记录 rand($table, $column, $where) rand($table, $join, $column, $where)
- pg_get_sum() : void
- 取总和 sum($table, $column, $where) sum($table, $join, $column, $where)
- pg_get_avg() : void
- 取平均值 avg($table, $column, $where) avg($table, $join, $column, $where)
- pg_raw() : mixed
- RAW https://medoo.in/api/raw raw('NOW()') raw('RAND()') raw('AVG(<age>)')
- pg_del() : mixed
- pg_delete() : mixed
- pg_tables() : void
- 显示所有表名
- pg_fields() : mixed
- 取表中字段
- pg_allow() : mixed
- 返回数据库允许的数据,传入其他字段自动忽略
- pg_tables_markdown() : mixed
- 显示数据库表结构,支持markdown格式
- pg_field_json() : mixed
- 取表中json字段
- pg_field_is_json() : mixed
- 判断表中的字段是不是json
- pg_row_json_to_array() : mixed
- 把数据库中json字段转成array
- array_order_by() : mixed
- is_json() : mixed
- add_action() : mixed
- do_action() : mixed
- pg_between_date() : mixed
- 返回两个日期之间 $date1 = '2022-11-01'; $date2 = '2022-12-14'; 字段是datetime类型
- pg_between_month() : mixed
- 返回两个月份之间 $date1 = '2022-11'; $date2 = '2022-12'; 字段是datetime类型
Functions
pg_active_main()
激活平台数据库连接,平台数据库不支持从库读
pg_active_main() : mixed
pg_active_read()
激活读数据库连接
pg_active_read() : mixed
pg_active_default()
激活默认数据库连接
pg_active_default() : mixed
pg_active()
激活当前使用哪个数据库
pg_active([mixed $name = 'default' ]) : mixed
Parameters
- $name : mixed = 'default'
get_pg_active_name()
获取当前启用的数据库连接
get_pg_active_name() : mixed
pg_can_run_action()
判断是否可运行action
pg_can_run_action() : mixed
pg_can_run_update()
数据库是否可执行更新操作
pg_can_run_update([mixed $sql = '' ]) : mixed
Parameters
- $sql : mixed = ''
new_pg()
连接数据库
new_pg([mixed $config = [] ][, mixed $name = '' ]) : mixed
Parameters
- $config : mixed = []
- $name : mixed = ''
medoo_pg()
数据库实例
medoo_pg() : object
Return values
objectpg()
pg() : mixed
pg_pager()
pg_pager(mixed $table, mixed $join[, mixed $columns = null ][, mixed $where = null ]) : mixed
Parameters
- $table : mixed
- $join : mixed
- $columns : mixed = null
- $where : mixed = null
pg_pager_count()
设置分页总记录数 一般情况用不到
pg_pager_count([mixed $nums = null ]) : mixed
Parameters
- $nums : mixed = null
pg_pager_html()
显示分页 调用pg_pager后,再调用。 pg_pager_html([ 'url'=>'', ]);
pg_pager_html([mixed $arr = [] ]) : mixed
Parameters
- $arr : mixed = []
pg_add_error()
添加错误信息
pg_add_error(mixed $str) : mixed
Parameters
- $str : mixed
pg_get_error()
获取错误信息
pg_get_error() : mixed
pg_get()
pg_get(mixed $table[, mixed $join = null ][, mixed $columns = null ][, mixed $where = null ]) : mixed
Parameters
- $table : mixed
- $join : mixed = null
- $columns : mixed = null
- $where : mixed = null
_pg_get()
_pg_get(mixed $table[, mixed $join = null ][, mixed $columns = null ][, mixed $where = null ]) : mixed
Parameters
- $table : mixed
- $join : mixed = null
- $columns : mixed = null
- $where : mixed = null
pg_select()
$lists = pg_select('do_order', [ 'count' => 'COUNT(`id`)', 'total' => 'SUM(`total_fee`)', 'date' => "FROM_UNIXTIME(`inserttime`, '%Y-%m-%d')" ], 'WHERE `status` = 1 GROUP BY `date` LIMIT 30' );
pg_select(mixed $table[, mixed $join = "*" ][, mixed $columns = null ][, mixed $where = null ]) : mixed
Parameters
- $table : mixed
- $join : mixed = "*"
- $columns : mixed = null
- $where : mixed = null
pg_insert()
写入记录
pg_insert(string $table[, array<string|int, mixed> $data = [] ][, mixed $don_run_action = false ]) : array<string|int, mixed>
Parameters
- $table : string
-
表名
- $data : array<string|int, mixed> = []
-
数据
- $don_run_action : mixed = false
Return values
array<string|int, mixed>pg_update()
更新记录
pg_update(string $table[, array<string|int, mixed> $data = [] ][, mixed $where = [] ][, mixed $don_run_action = false ]) : array<string|int, mixed>
Parameters
- $table : string
-
表名
- $data : array<string|int, mixed> = []
-
数据
- $where : mixed = []
- $don_run_action : mixed = false
Return values
array<string|int, mixed>pg_action()
数据库事务
pg_action(mixed $call) : mixed
Parameters
- $call : mixed
pg_for_update()
对数据进行
pg_for_update(mixed $table, mixed $id) : mixed
Parameters
- $table : mixed
- $id : mixed
pg_get_one()
根据表名、字段 、条件 查寻一条记录
pg_get_one(string $table[, mixed $join = "*" ][, mixed $columns = null ][, array<string|int, mixed> $where = null ]) : array<string|int, mixed>
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $columns : mixed = null
- $where : array<string|int, mixed> = null
-
条件
Return values
array<string|int, mixed>pg_query()
SQL查寻
pg_query(mixed $sql[, mixed $raw = null ]) : mixed
Parameters
- $sql : mixed
- $raw : mixed = null
pg_get_min()
取最小值 https://medoo.in/api/min min($table, $column, $where) min($table, $join, $column, $where)
pg_get_min(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : string = null
-
字段
- $where : array<string|int, mixed> = null
-
条件
pg_get_max()
取最大值 max($table, $column, $where) max($table, $join, $column, $where)
pg_get_max(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : string = null
-
字段
- $where : array<string|int, mixed> = null
-
条件
pg_get_count()
总数 count($table, $where) count($table, $join, $column, $where)
pg_get_count(string $table[, mixed $join = "*" ][, mixed $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : mixed = null
- $where : array<string|int, mixed> = null
-
条件
pg_get_has()
是否有记录 has($table, $where) has($table, $join, $where)
pg_get_has(string $table[, mixed $join = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = null
- $where : array<string|int, mixed> = null
-
条件
pg_get_rand()
随机取多条记录 rand($table, $column, $where) rand($table, $join, $column, $where)
pg_get_rand(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : string = null
-
字段
- $where : array<string|int, mixed> = null
-
条件
pg_get_sum()
取总和 sum($table, $column, $where) sum($table, $join, $column, $where)
pg_get_sum(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : string = null
-
字段
- $where : array<string|int, mixed> = null
-
条件
pg_get_avg()
取平均值 avg($table, $column, $where) avg($table, $join, $column, $where)
pg_get_avg(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
Parameters
- $table : string
-
表名
- $join : mixed = "*"
- $column : string = null
-
字段
- $where : array<string|int, mixed> = null
-
条件
pg_raw()
RAW https://medoo.in/api/raw raw('NOW()') raw('RAND()') raw('AVG(<age>)')
pg_raw(string $raw) : mixed
Parameters
- $raw : string
pg_del()
pg_del(mixed $table, mixed $where) : mixed
Parameters
- $table : mixed
- $where : mixed
pg_delete()
pg_delete(mixed $table, mixed $where) : mixed
Parameters
- $table : mixed
- $where : mixed
pg_tables()
显示所有表名
pg_tables(string $table) : void
Parameters
- $table : string
-
表名
Tags
pg_fields()
取表中字段
pg_fields(mixed $table[, mixed $has_key = true ]) : mixed
Parameters
- $table : mixed
- $has_key : mixed = true
pg_allow()
返回数据库允许的数据,传入其他字段自动忽略
pg_allow(mixed $table, mixed $data) : mixed
Parameters
- $table : mixed
- $data : mixed
pg_tables_markdown()
显示数据库表结构,支持markdown格式
pg_tables_markdown([string $name = null ][, mixed $show_markdown = false ]) : mixed
Parameters
- $name : string = null
-
数据库名
- $show_markdown : mixed = false
Tags
pg_field_json()
取表中json字段
pg_field_json(mixed $table) : mixed
Parameters
- $table : mixed
pg_field_is_json()
判断表中的字段是不是json
pg_field_is_json(mixed $table, mixed $field) : mixed
Parameters
- $table : mixed
- $field : mixed
pg_row_json_to_array()
把数据库中json字段转成array
pg_row_json_to_array( $table_name[, &$row_data = [] ]) : mixed
Parameters
array_order_by()
array_order_by() : mixed
is_json()
is_json(mixed $data[, mixed $assoc = false ]) : mixed
Parameters
- $data : mixed
- $assoc : mixed = false
add_action()
add_action(mixed $name, mixed $call[, mixed $level = 20 ]) : mixed
Parameters
- $name : mixed
- $call : mixed
- $level : mixed = 20
do_action()
do_action(mixed $name[, mixed &$par = null ]) : mixed
Parameters
- $name : mixed
- $par : mixed = null
pg_between_date()
返回两个日期之间 $date1 = '2022-11-01'; $date2 = '2022-12-14'; 字段是datetime类型
pg_between_date(mixed $field, mixed $date1, mixed $date2) : mixed
Parameters
- $field : mixed
- $date1 : mixed
- $date2 : mixed
pg_between_month()
返回两个月份之间 $date1 = '2022-11'; $date2 = '2022-12'; 字段是datetime类型
pg_between_month(mixed $field, mixed $date1, mixed $date2) : mixed
Parameters
- $field : mixed
- $date1 : mixed
- $date2 : mixed