PHP新的连接MySQL方法mysqli

PHP新的连接MySQL方法mysqli

1. 开启PHP的API支持
(1)首先修改您的php.ini的配置文件。
      查找下面的语句:
      ;extension=php_mysqli.dll
      将其修改为:
      extension=php_mysqli.dll
(2)重新启动Apache/IIS,即可。
(3)说明:PHP需要单独的文件来支持这个扩展库,一般在PHP目录下的ext目录里能找到php_mysqli.dll文件(PHP <=5.0.2 中是libmysqli.dll),当然,在PHP的配置文件当中要有正确指向ext的信息(extension_dir)。假若您的PHP没有这个文件,您可以去下载PHP5的源码包。另外,这个API扩展,只能在PHP5以上版本使用。其它具体信息,请看下面。
2. mysqli身份证
mysqli是“MySQL, Improved”的缩写,该扩展仅适用于PHP 5。它能用于MySQL4.1.1和更高版本。该扩展完全支持MySQL5.1中采用的鉴定协议,也支持预处理语句和多语句API。此外,该扩展还提供了先进的、面向对象的编程接口。在http://php.net/mysqli上,可找到关于mysqli扩展的文档。在http://www.zend.com/php5/articles/php5-mysqli.php处,给出了一篇有用的文章。
3. mysqli预定义类
mysqli
表达了 PHP 和 MySQL 数据库之间的连接。

构造函数
mysqli - 构造一个新的 mysqli 对象
方法
autocommit - 打开或关闭自动提交的数据库选项
change_user - 改变指定的数据库连接的用户
character_set_name - 返回数据库连接的默认字符集
close - 关闭一个之前打开的连接
commit - 提交当前事务
connect - 打开一个到 MySQL 数据库服务器的新连接
debug - 执行排错操作
dump_debug_info - 取得排错信息
get_client_info - 返回客户端版本
get_host_info - 返回连接使用的类型
get_server_info - 返回 MySQL 服务器的版本
get_server_version - 返回 MySQL 服务器的版本
init - 初始化 mysqli 对象
info - 取得最近执行的查询的信息
kill - 要求服务器停止一个 mysql 线程
multi_query - 执行多个查询
more_results - check if more results exist from currently executed multi-query
next_result - reads next result from currently executed multi-query
options - set options
ping - pings a server connection or reconnects if there is no connection
prepare - prepares a SQL query
query - performs a query
real_connect - attempts to open a connection to MySQL database server
escape_string - escapes special characters in a string for use in a SQLstatement, taking into account the current charset of the connection
rollback - rolls back the current transaction
select_db - selects the default database
set_charset - sets the default client character set
ssl_set - sets ssl parameters
stat - gets the current system status
stmt_init- initializes a statement for use with mysqli_stmt_prepare
store_result - transfers a resultset from last query
thread_safe - returns whether thread safety is given or not
use_result - transfers an unbuffered resultset from last query
属性
affected_rows - gets the number of affected rows in a previous MySQL operation
client_info - returns the MySQL client version as a string
client_version - returns the MySQL client version as an integer
errno - returns the error code for the most recent function call
error - returns the error string for the most recent function call
field_count - returns the number of columns for the most recent query
host_info - returns a string representing the type of connection used
info - retrieves information about the most recently executed query
insert_id - returns the auto generated id used in the last query
protocol_version - returns the version of the MySQL protocol used
server_info - returns a string that represents the server version number
server_version - returns the version number of the server as an integer
sqlstate - returns a string containing the SQLSTATE error code for the last error
thread_id - returns the thread ID for the current connection
warning_count - returns the number of warnings generated during execution of the previous SQL statement

 

 

补充类:


mysqli_affected_rows -返回一个MySQL操作受影响的行数
mysqli_autocommit -开启或关闭 autocommit 数据库修改
mysqli_bind_param -别名mysqli_stmt_bind_param ( )
mysqli_bind_result -别名mysqli_stmt_bind_result ( )
mysqli_change_user -更改指定数据库连接的用户
mysqli_character_set_name -返回数据库连接的默认字符集
mysqli_client_encoding -别名mysqli_character_set_name ( )
mysqli_close -关闭当前打开数据库连接
mysqli_commit -当前事物
mysqli_connect_errno -返回最后一次操作的错误代码
mysqli_connect_error -返回最后一次操作的错误字符串描述
mysqli_connect -打开一个新的连接到MySQL服务器
mysqli_data_seek -在当前记录结果集中任意移动行指针
mysqli_debug -调试
mysqli_disable_reads_from_master -禁用读取主对像
mysqli_disable_rpl_parse -禁用RPL解析
mysqli_dump_debug_info -转储调试信息的日志
mysqli_embedded_connect -打开一个连接到嵌入式MySQL服务器
mysqli_enable_reads_from_master -启用内容由主
mysqli_enable_rpl_parse -启用RPL解析
mysqli_errno -返回错误代码最近函数调用
mysqli_error -返回一个字符串描述过去的错误
mysqli_escape_string -别名mysqli_real_escape_string ( )
mysqli_execute -别名mysqli_stmt_execute ( )
mysqli_fetch_array -从结果集中取得一行作为关联,数字数组,或两者兼施
mysqli_fetch_assoc -从结果集中取得一行作为关联数组
mysqli_fetch_field_direct -获取元数据的一个单一的领域
mysqli_fetch_field -返回明年领域中的结果集
mysqli_fetch_fields -返回一个数组对象代表领域的结果集
mysqli_fetch_lengths -返回长度列的当前行的结果集
mysqli_fetch_object -返回当前行的结果集作为一个对象
mysqli_fetch_row -取得结果集中取得一行作为枚举数组
mysqli_fetch -别名mysqli_stmt_fetch ( )
mysqli_field_count -返回的列数最近查询
mysqli_field_seek -设为结果指针到指定的外地抵消
mysqli_field_tell -获取当前外地抵消的结果指针
mysqli_free_result -释放内存与结果
mysqli_get_client_info -返回MySQL客户端版本作为一个字符串
mysqli_get_client_version -取得MySQL客户端信息
mysqli_get_host_info -返回一个字符串代表的连接类型使用
mysqli_get_metadata -别名mysqli_stmt_result_metadata ( )
mysqli_get_proto_info -返回版本的MySQL使用协议
mysqli_get_server_info -返回版本的MySQL服务器
mysqli_get_server_version -返回版本的MySQL服务器作为一个整数
mysqli_info -检索信息,最近执行的查询
mysqli_init -初始化MySQLi并返回一个资源使用mysqli_real_connect ( )
mysqli_insert_id -返回自动生成的编号使用最后查询
mysqli_kill -要求服务器要杀死一个MySQL线程
mysqli_master_query -强制执行查询总在主/从设置
mysqli_more_results -检查是否有任何更多的查询结果来自一个多查询
mysqli_multi_query -执行查询数据库
mysqli_next_result -准备明年的结果multi_query
mysqli_num_fields -获取的若干领域中的结果
mysqli_num_rows -获取的行数的结果
mysqli_options -设置选项
mysqli_param_count -别名mysqli_stmt_param_count ( )
mysqli_ping -的Ping一个服务器连接,或尝试重新连接,如果已下降
mysqli_prepare -准备一个SQL语句的执行
mysqli_query -执行查询数据库
mysqli_real_connect -打开一个连接到MySQL服务器
mysqli_real_escape_string -转义特殊字符的字符串,用于SQL语句,并考虑到当前的字符集的连接
mysqli_real_query -执行一个SQL查询
mysqli_report -启用或禁用内部报告功能
mysqli_rollback -回滚当前事务
mysqli_rpl_parse_enabled -检查是否启用RPL解析
mysqli_rpl_probe - RPL探针
mysqli_rpl_query_type -返回RPL查询类型
mysqli_select_db -选择的默认数据库数据库查询
mysqli_send_long_data -别名mysqli_stmt_send_long_data ( )
mysqli_send_query -发送查询并返回
mysqli_server_end -关机嵌入式服务器
mysqli_server_init -初始化嵌入式服务器
mysqli_set_charset -集的默认客户端字符集
mysqli_set_opt -别名mysqli_options ( )
mysqli_sqlstate -返回SQLSTATE错误从一个MySQL操作
mysqli_ssl_set -用于建立安全连接使用SSL
mysqli_stat -获取当前的系统状态
mysqli_stmt_affected_rows -返回总数列改变,删除或插入的最后执行的声明
mysqli_stmt_bind_param -绑定变量一份声明作为参数
mysqli_stmt_bind_result -绑定变量的一份声明中存储的结果
mysqli_stmt_close -关闭一份声明
mysqli_stmt_data_seek -寻找一个任意行声明的结果集
mysqli_stmt_errno -返回错误代码的最新声明呼吁
mysqli_stmt_error -返回一个字符串描述最后声明错误
mysqli_stmt_execute -执行一个准备查询
mysqli_stmt_fetch -获取结果一份准备好的声明中纳入约束变量
mysqli_stmt_free_result -免储存记忆的结果给予处理的声明
mysqli_stmt_init -初始化了言,并返回一个对象,用于mysqli_stmt_prepare
mysqli_stmt_num_rows -返回的行数报表结果集
mysqli_stmt_param_count -返回一些参数给定的声明
mysqli_stmt_prepare -准备一个SQL语句的执行
mysqli_stmt_reset -重置一份声明
mysqli_stmt_result_metadata -返回结果集元数据的一份书面声明
mysqli_stmt_send_long_data -发送数据块
mysqli_stmt_sqlstate -返回SQLSTATE错误行动从以往的声明
mysqli_stmt_store_result -转让的结果集由一份声明
mysqli_store_result -转让的结果集的最后查询
mysqli_thread_id -返回线程ID为当前连接
mysqli_thread_safe -返回是否线程安全考虑或不
mysqli_use_result -开创检索结果集
mysqli_warning_count -返回一些警告过去查询提供链接

 


4. 基本语法

 

 

英文原版:

 

 

MySQL Improved Extension

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值