微赞php.ini

编程入门 行业动态 更新时间:2024-10-06 18:26:56

<a href=https://www.elefans.com/category/jswz/34/1745155.html style=微赞php.ini"/>

微赞php.ini

系统数据库操作函数全部位于 framework/function/db.func.php 文件内。

注意:系统会默认加载该文件,因此该文件内所有函数均可直接使用。

1.pdo_debug

array pdo_debug([boolean $output], [array $append]);

获取pdo操作错误信息列表

$output boolean 是否要输出执行记录和执行错误信息

$append array 加入执行信息,如果此参数不为空则 $output 参数为 false

获取pdo操作错误信息列表,返回由 SQL 语句、参数列表、错误代码组成的数组。

$sql = ‘SELECT * FROM ‘ . tablename(‘account’) . ‘ WHERE `acid` = :acid’; $params = array(‘:uniacid’ ⇒ 123, array(100)); $account = pdo_fetch($sql, $params); pdo_debug(true);

…… Array (

[sql] => SELECT * FROM `ims_account` WHERE `acid` = :acid

[params] => Array

(

[:uniacid] => 123

[0] => Array

(

[0] => 100

)

)

[error] => Array

(

[0] => HY093

[1] =>

[2] =>

)

)

……

2.pdo_delete

mixed pdo_delete(string $table, array $params, string $glue);

删除记录

$table string 数据表名

$params array 参数列表

$glue string 条件类型 可以为AND OR

删除记录,如果删除成功返回影响行数,失败返回 false。

pdo_delete(‘account’, array(‘uniacid’ ⇒ ‘200’));

3.pdo_fetch

mixed pdo_fetch(string $sql, [array $params]);

执行SQL返回第一行

$sql string 需要执行的SQL语句

$params array 参数列表

执行SQL返回第一行, 如果参数列表错误,返回 false,否则返回 SQL 结果。

$sql = ‘SELECT * FROM ‘ . tablename(‘account’) . ‘ WHERE `acid` = :acid’; $params = array(‘:acid’ ⇒ ‘111’); $account = pdo_fetch($sql, $params); print_r($account);

Array (

[acid] => 111

[uniacid] => 181

[hash] => YNG66gt4

[type] => 1

[isconnect] => 1

)

pdo_fetchall mixed pdo_fetchall(string $sql, [array $params], [string $keyfield]);

执行SQL返回全部记录

$sql string 需要执行的SQL语句

$params array 参数列表

$keyfield string 将该字段的值作为结果索引

执行SQL返回全部记录, 如果参数列表错误,返回 false。如果可选参数 $keyfield 不为空,则将该字段的值作为结果数组索引。

$sql = ‘SELECT * FROM ‘ . tablename(‘account’) . ‘ WHERE `acid` > :acid’; $params = array(‘:acid’ ⇒ ‘400’); $accounts = pdo_fetchall($sql, $params); print_r($accounts);

Array (

[0] => Array

(

[acid] => 434

[uniacid] => 288

[hash] => M3BaP3WR

[type] => 1

[isconnect] => 0

)

[1] => Array

(

[acid] => 433

[uniacid] => 288

[hash] => I01dujgC

[type] => 1

[isconnect] => 0

)

[2] => Array

(

[acid] => 440

[uniacid] => 444

[hash] => E33pwA88

[type] => 1

[isconnect] => 1

)

)

4.pdo_fetchallfields

array pdo_fetchallfields(string $tablename);

获取所有字段名称

$tablename string 数据表名

获取所有字段名称

$fields = pdo_fetchallfields(tablename(‘account’)); print_r($fields); Array ( [0] ⇒ acid

[1] => uniacid

[2] => hash

[3] => type

[4] => isconnect

)

5.pdo_fetchcolumn

mixed pdo_fetchcolumn(string $sql, [array $params], [int $column]);

执行SQL返回第一个字段

$sql string 需要执行的SQL语句

$params array 参数列表

$column int 返回查询结果的某列,默认为第一列

执行SQL语句,返回一列数据,默认为第一列。

$sql = ‘SELECT COUNT(*) FROM ‘ . tablename(‘account’); $total = pdo_fetchcolumn($sql);

echo $total; 1000 ===== pdo_fieldexists ===== boolean pdo_fieldexists(string $tablename, [string $filedname]); 查询字段是否存在 ||参数 $tablename string 查询表名 $fieldname string 查询字段名 ||返回值 查询字段是否存在于指定数据表中 ||示例 $exists = pdo_fieldexists(‘account’, ‘acid2’); echo $exists; false

6.pdo_indexexists

boolean pdo_indexexists(string $tablename, [string $indexname]);

查询索引是否存在

$tablename string 查询表名

$indexname string 查询字段名

查询索引是否存在于指定数据表中

$exists = pdo_indexexists(‘account’, ‘acid2’); echo $exists; false ===== pdo_insert ===== mixed pdo_insert(string $table, [array $data], [boolean $replace]); 添加或更新纪录 ||参数 $table string 数据表名 $data array 插入数据 $replace boolean 是否执行REPLACE INTO ||返回值 添加或更新纪录,如果添加成功返回 true,否则返回 false。如果可选参数 $replace 为 true,则执行REPLACE INTO,如果更新成功,返回影响行数,否则插入一条新数据。 ||示例 $account = pdo_insert(‘account’, array(‘uniacid’ ⇒ 200)); echo $account; true pdo_insertid int pdo_insertid();

获取上一步 INSERT 操作产生的 ID

获取上一步 INSERT 操作产生的 ID,如果失败或没有 Insert 操作,则返回 false。

pdo_insert(‘account’, array(‘uniacid’ ⇒ 200)); $newId = pdo_insertid(); echo $newId;

7.pdo_query

boolean int pdo_query(string $sql, [array $params]);

执行一条非查询语句

$sql string 需要执行的SQL语句

$params array 参数列表

执行一条非查询语句,成功返回受影响的行数,失败返回FALSE。

创建一个数据表 $sql = ‘CREATE TABLE `ims_account` ( `acid` int(10) unsigned NOT NULL AUTO_INCREMENT, `uniacid` int(10) unsigned NOT NULL, `hash` varchar(8) NOT NULL, `type` tinyint(3) unsigned NOT NULL DEFAULT ‘1’ COMMENT ‘1为微信,2为易信’, `isconnect` tinyint(1) NOT NULL DEFAULT ‘0’, PRIMARY KEY (`acid`), KEY `idx_uniacid` (`uniacid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8′; pdo_query($sql); pdo_run void pdo_run(string $sql); ||参数 $sql string 需要执行的SQL语句 ||返回值 ^void ||示例 创建两个数据表

$sql = ‘CREATE TABLE `ims_account` ( `acid` int(10) unsigned NOT NULL AUTO_INCREMENT, `uniacid` int(10) unsigned NOT NULL, `hash` varchar(8) NOT NULL, `type` tinyint(3) unsigned NOT NULL DEFAULT ‘1’ COMMENT ‘1为微信,2为易信’, `isconnect` tinyint(1) NOT NULL DEFAULT ‘0’, PRIMARY KEY (`acid`), KEY `idx_uniacid` (`uniacid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; ‘CREATE TABLE `ims_account` ( `acid` int(10) unsigned NOT NULL AUTO_INCREMENT, `uniacid` int(10) unsigned NOT NULL, `hash` varchar(8) NOT NULL, `type` tinyint(3) unsigned NOT NULL DEFAULT ‘1’ COMMENT ‘1为微信,2为易信’, `isconnect` tinyint(1) NOT NULL DEFAULT ‘0’, PRIMARY KEY (`acid`), KEY `idx_uniacid` (`uniacid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;’;

pdo_run($sql);

8.pdo_tableexists

boolean pdo_tableexists(string $tablename);

检测数据表是否存在

$tablename string 数据表名

检测数据表是否存在,如果存在返回 true, 否则返回 false。

$exists = pdo_tableexists(‘account’); print_r($exists); true ===== pdo_update ===== mixed pdo_update(string $table, [array $data], [array $params], [string $glue]); ||更新记录 ||参数 $table string 数据表名 $data array 更新记录 $params array 更新参数 $glue string 条件类型 可以为AND OR ||返回值 更新数据表记录,如果更新成功,返回影响行数,否则返回 fasle。 ||示例 pdo_update(‘account’, array(‘uniacid’ ⇒ ‘100’), array(‘acid’ ⇒ ’10’));

开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明微赞微擎二开笔记开发手册之数据库操作函数(十二)!

更多推荐

微赞php.ini

本文发布于:2024-02-27 16:03:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1707268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:微赞   php   ini

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!