2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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 -返回一些警告过去查询提供链接

转载于:https://my.oschina.net/ajian2014/blog/308462

PHP新的连接MySQL方法mysqli相关推荐

  1. sas eg连接mysql_SAS通过odbc连接mysql方法

    SAS使用odbc连接mysql方法: 一.从mysql数据库官网下载mysql和mysql odbc driver并安装. 二.安装完之后,在控制面板-管理工具-数据源-驱动程序,添加mysql驱动 ...

  2. 狐表 mysql_狐表成功连接MySql方法教程小结,可查询 可回写 字段名可显示中文...

    相信很多人都在狐表论坛里搜素mysql,然后看怎么连接mysql,其实需求不是很多,就是能把mysql的表简单读出来,然后可以简单回写一下,就足够了. 然而关于Mysql的代码和教程总是到处飞,到处连 ...

  3. mysql codesmith_CodeSmith连接Mysql方法步骤

    版本信息: 1. codesmith 7.0 2. mysql-connector-net-6.7.4.msi 文件:CodeSmith.exe.config 内容 其中System.data段为连接 ...

  4. 微信小程序通过 node 连接 mysql——方法,简要原理,及一些常见问题

    前言 博主自己在22年夏天根据课程要求做了一个小程序连接阿里云服务器的案例,在最近又碰到了相应的需求. 原参考文章:微信小程序 Node连接本地MYSQL_微信小程序nodejs连接数据库_JJJen ...

  5. jsp 连接 mysql 方法_jsp连接数据库的几种方式

    ---恢复内容开始--- jsp连接数据库分为:JDBC-ODBC桥接方式.数据库驱动程序连接(新手笔记,若有错误请大神指出). 桥接方式: 连接Access数据库: 首先要在Access中建立一个数 ...

  6. 【Tableau Desktop 企业日常技巧16】Tableau下载和安装ODBC驱动 连接MySQL方法及过程详解

    文章目录 下载 ODBC配置 tableau 测试连接 下载 ODBC驱动链接:https://downloads.mysql.com/archives/c-odbc/ 依顺序打开 开始菜单 > ...

  7. DBeaver连接MySql方法

    解决方式: 打开"窗口"->"首选项"->"驱动"->"Maven" 点击"添加" ...

  8. mysql 百度bae乱码 php,[PHP]如何在百度(BAE)和新浪(SAE)的云平台使用PHP连接MySQL并返...

    以下是BAE的连接MySQL方法.基本的调用和PHP的相关MySQL函数一样: mysql_query - 发送一条 MySQL 查询 mysql_fetch_array - 从结果集中取得一行作为关 ...

  9. php通过Mysqli和PDO连接mysql数据详解

    前言 在实际开发中,关于数据库操作类,很少是自己去写,大多是通过一些框架去实现,突然自己去写,还是需要借阅手册之类,于是我觉得有必要去总结一下,php连接mysql的方法,php连接mysql,可以通 ...

最新文章

  1. KiFastCallEntry() 机制分析
  2. 每日一博 - tcpdump小技巧
  3. 如何在Java中将String转换为int
  4. cmdline常用参数
  5. 快手小剧场推出独立APP“追鸭”
  6. 从输入URL到页面加载完成的过程中都发生了什么事情?
  7. 通用设备的动态DMA映射
  8. Autofac 依赖注入框架 使用
  9. 奥维中如何关闭gcj02坐标_QGIS入门知识:啥是坐标系
  10. 【读书笔记《Bootstrap 实战》】4.企业网站
  11. Gitlab文件管理之把文档传到指定文件夹
  12. 决策树first task之框架搭建和提出问题
  13. 按照账号定位持续发视频,数据不会太差!
  14. 使用FileDownloader下载文件(举例版本更新下载apk文件)
  15. 超过1M的网络动图添加到微信表情包
  16. wx微信小程序实现通讯录
  17. Serenity Screenplay pom.xml文件配置
  18. 设计师常用的三维制图软件有哪些
  19. Pro/E Wildfire3.0二次开发环境配置
  20. GPIO口,上下拉电阻与推挽输出

热门文章

  1. 道路上下行是什么意思_了解道路禁止符号 春节压岁钱少填罚款
  2. 深入理解基本包装类型
  3. 计算机的cpu怎么设计出来的,CPU是如何制作出来的?cpu的制造流程介绍
  4. [Vue-cli3] is a Vue CLI 3 only command and you are using Vue CLI 2.9.6. You may...
  5. codesys中打开linux端的串口_干货分享——安卓串口通信
  6. Spring MVC前后台交互(前台ajax传递数据,后台controller接收数据返回json对象)
  7. Android Studio两模块间getLaunchIntentForPackage跳转,出现intent为null,已解决
  8. 20210601:力扣第243周周赛(上)
  9. 光影之路 GPU架构发展史(4/4)
  10. VB将自定义资源中的文件释放出来