参考自php手册。本文没有太大意义,仅为方便自己上网查阅。

1、PHP的MySQL扩展
2、PHP的mysqli扩展
3、PHP数据对象(PDO)

MySQL扩展函数
这是设计开发允许PHP应用与MySQL数据库交互的早期扩展。mysql扩展提供了一个面向过程 的接口,并且是针对MySQL4.1.3或更早版本设计的。因此,这个扩展虽然可以与MySQL4.1.3或更新的数据库服务端 进行交互,但并不支持后期MySQL服务端提供的一些特性。

mysql_affected_rows — 取得前一次 MySQL 操作所影响的记录行数
mysql_client_encoding — 返回字符集的名称
mysql_close — 关闭 MySQL 连接
mysql_connect — 打开一个到 MySQL 服务器的连接
mysql_create_db — 新建一个 MySQL 数据库
mysql_data_seek — 移动内部结果的指针
mysql_db_name — 取得结果数据
mysql_db_query — 发送一条 MySQL 查询
mysql_drop_db — 丢弃(删除)一个 MySQL 数据库
mysql_errno — 返回上一个 MySQL 操作中的错误信息的数字编码
mysql_error — 返回上一个 MySQL 操作产生的文本错误信息
mysql_escape_string — 转义一个字符串用于 mysql_query
mysql_fetch_array — 从结果集中取得一行作为关联数组,或数字数组,或二者兼有
mysql_fetch_assoc — 从结果集中取得一行作为关联数组
mysql_fetch_field — 从结果集中取得列信息并作为对象返回
mysql_fetch_lengths — 取得结果集中每个输出的长度
mysql_fetch_object — 从结果集中取得一行作为对象
mysql_fetch_row — 从结果集中取得一行作为枚举数组
mysql_field_flags — 从结果中取得和指定字段关联的标志
mysql_field_len — 返回指定字段的长度
mysql_field_name — 取得结果中指定字段的字段名
mysql_field_seek — 将结果集中的指针设定为制定的字段偏移量
mysql_field_table — 取得指定字段所在的表名
mysql_field_type — 取得结果集中指定字段的类型
mysql_free_result — 释放结果内存
mysql_get_client_info — 取得 MySQL 客户端信息
mysql_get_host_info — 取得 MySQL 主机信息
mysql_get_proto_info — 取得 MySQL 协议信息
mysql_get_server_info — 取得 MySQL 服务器信息
mysql_info — 取得最近一条查询的信息
mysql_insert_id — 取得上一步 INSERT 操作产生的 ID
mysql_list_dbs — 列出 MySQL 服务器中所有的数据库
mysql_list_fields — 列出 MySQL 结果中的字段
mysql_list_processes — 列出 MySQL 进程
mysql_list_tables — 列出 MySQL 数据库中的表
mysql_num_fields — 取得结果集中字段的数目
mysql_num_rows — 取得结果集中行的数目
mysql_pconnect — 打开一个到 MySQL 服务器的持久连接
mysql_ping — Ping 一个服务器连接,如果没有连接则重新连接
mysql_query — 发送一条 MySQL 查询
mysql_real_escape_string — 转义 SQL 语句中使用的字符串中的特殊字符,并考虑到连接的当前字符集
mysql_result — 取得结果数据
mysql_select_db — 选择 MySQL 数据库
mysql_set_charset — Sets the client character set
mysql_stat — 取得当前系统状态
mysql_tablename — 取得表名
mysql_thread_id — 返回当前线程的 ID
mysql_unbuffered_query — 向 MySQL 发送一条 SQL 查询,并不获取和缓存结果的行
PHP的mysqli扩展
mysqli扩展,我们有时称之为MySQL增强扩展,可以用于使用 MySQL4.1.3或更新版本中新的高级特性。mysqli扩展在PHP 5及以后版本中包含。

面向对象接口
prepared语句支持
多语句执行支持
事务支持
增强的调试能力
嵌入式服务支持
如果你使用MySQL4.1.3或更新版本,强烈建议你使用这个扩展。
MySQLi {

/* 属性 */
int $MySQLi->affected_rows;
string $client_info;
int $client_version;
string $connect_errno;
string $connect_error;
int $errno;
string $error;
int $field_count;
int $client_version;
string $host_info;
string $protocol_version;
string $server_info;
int $server_version;
string $info;
mixed $insert_id;
string $sqlstate;
int $thread_id;
int $warning_count;
/* 方法 */
int mysqli_affected_rows ( mysqli$link )
bool mysqli::autocommit ( bool$mode )
bool mysqli::change_user ( string$user ,string$password ,string$database )
string mysqli::character_set_name ( void )
string mysqli_get_client_info ( mysqli$link )
int mysqli_get_client_version ( mysqli$link )
bool mysqli::close ( void )
bool mysqli::commit ( void )
int mysqli_connect_errno ( void )
string mysqli_connect_error ( void )
mysqli mysqli_connect ([ string$host = ini_get("mysqli.default_host") [,string$username = ini_get("mysqli.default_user") [,string$passwd = ini_get("mysqli.default_pw") [,string$dbname = "" [,int $port = ini_get("mysqli.default_port") [,string$socket = ini_get("mysqli.default_socket") ]]]]]] )
bool mysqli::debug ( string$message )
bool mysqli::dump_debug_info ( void )
int mysqli_errno ( mysqli$link )
string mysqli_error ( mysqli$link )
int mysqli_field_count ( mysqli$link )
object mysqli::get_charset ( void )
string mysqli::get_client_info ( void )
array mysqli_get_client_stats ( void )
int mysqli_get_client_version ( mysqli$link )
bool mysqli::get_connection_stats ( void )
string mysqli_get_host_info ( mysqli$link )
int mysqli_get_proto_info ( mysqli$link )
string mysqli_get_server_info ( mysqli$link )
int mysqli_get_server_version ( mysqli$link )
mysqli_warningmysqli::get_warnings (void )
string mysqli_info ( mysqli$link )
mysqli mysqli::init ( void )
mixed mysqli_insert_id ( mysqli$link )
bool mysqli::kill ( int $processid )
bool mysqli::more_results ( void )
bool mysqli::multi_query ( string$query )
bool mysqli::next_result ( void )
bool mysqli::options ( int$option ,mixed$value )
bool mysqli::ping ( void )
public int mysqli::poll ( array &$read ,array&$error , array&$reject ,int $sec [,int $usec ] )
mysqli_stmt mysqli::prepare ( string$query )
mixed mysqli::query ( string$query [,int$resultmode ] )
bool mysqli::real_connect ([ string$host [,string$username [,string$passwd [,string$dbname [,int$port [,string$socket [,int$flags ]]]]]]] )
string mysqli::escape_string ( string$escapestr )
bool mysqli::real_query ( string$query )
public mysqli_result mysqli::reap_async_query (void )
bool mysqli::rollback ( void )
bool mysqli::select_db ( string$dbname )
bool mysqli::set_charset ( string$charset )
void mysqli_set_local_infile_default ( mysqli$link )
bool mysqli::set_local_infile_handler ( mysqli$link ,callback$read_func )
string mysqli_sqlstate ( mysqli$link )
bool mysqli::ssl_set ( string$key ,string$cert ,string$ca ,string$capath ,string$cipher )
string mysqli::stat ( void )
mysqli_stmt mysqli::stmt_init ( void )
mysqli_resultmysqli::store_result (void )
int mysqli_thread_id ( mysqli$link )
bool mysqli_thread_safe ( void )
mysqli_resultmysqli::use_result (void )
int mysqli_warning_count ( mysqli$link )
}

Table of Contents
mysqli->affected_rows — Gets the number of affected rows in a previous MySQL operation
mysqli::autocommit — Turns on or off auto-commiting database modifications
mysqli::change_user — Changes the user of the specified database connection
mysqli::character_set_name — Returns the default character set for the database connection
mysqli->client_info — Returns the MySQL client version as a string
mysqli->client_version — Get MySQL client info
mysqli::close — Closes a previously opened database connection
mysqli::commit — Commits the current transaction
mysqli->connect_errno — Returns the error code from last connect call
mysqli->connect_error — Returns a string description of the last connect error
mysqli::__construct — Open a new connection to the MySQL server
mysqli::debug — Performs debugging operations
mysqli::dump_debug_info — Dump debugging information into the log
mysqli->errno — Returns the error code for the most recent function call
mysqli->error — Returns a string description of the last error
mysqli->field_count — Returns the number of columns for the most recent query
mysqli::get_charset — Returns a character set object
mysqli->get_client_info — Returns the MySQL client version as a string
mysqli_get_client_stats — Returns client per-process statistics
mysqli->client_version — Get MySQL client info
mysqli::get_connection_stats — Returns statistics about the client connection
mysqli->host_info — Returns a string representing the type of connection used
mysqli->protocol_version — Returns the version of the MySQL protocol used
mysqli->server_info — Returns the version of the MySQL server
mysqli->server_version — Returns the version of the MySQL server as an integer
mysqli::get_warnings — Get result of SHOW WARNINGS
mysqli->info — Retrieves information about the most recently executed query
mysqli::init — Initializes MySQLi and returns a resource for use with mysqli_real_connect()
mysqli->insert_id — Returns the auto generated id used in the last query
mysqli::kill — Asks the server to kill a MySQL thread
mysqli::more_results — Check if there are any more query results from a multi query
mysqli::multi_query — Performs a query on the database
mysqli::next_result — Prepare next result from multi_query
mysqli::options — Set options
mysqli::ping — Pings a server connection, or tries to reconnect if the connection has gone down
mysqli::poll — Poll connections
mysqli::prepare — Prepare an SQL statement for execution
mysqli::query — Performs a query on the database
mysqli::real_connect — Opens a connection to a mysql server
mysqli::real_escape_string — Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
mysqli::real_query — Execute an SQL query
mysqli::reap_async_query — Get result from async query
mysqli::rollback — Rolls back current transaction
mysqli::select_db — Selects the default database for database queries
mysqli::set_charset — Sets the default client character set
mysqli::set_local_infile_default — Unsets user defined handler for load local infile command
mysqli::set_local_infile_handler — Set callback function for LOAD DATA LOCAL INFILE command
mysqli->sqlstate — Returns the SQLSTATE error from previous MySQL operation
mysqli::ssl_set — Used for establishing secure connections using SSL
mysqli::stat — Gets the current system status
mysqli::stmt_init — Initializes a statement and returns an object for use with mysqli_stmt_prepare
mysqli::store_result — Transfers a result set from the last query
mysqli->thread_id — Returns the thread ID for the current connection
mysqli::thread_safe — Returns whether thread safety is given or not
mysqli::use_result — Initiate a result set retrieval
mysqli->warning_count — Returns the number of warnings from the last query for the given link

PHP数据对象(PDO)
PHP数据对象,是PHP应用中的一个数据库抽象层规范。PDO提供了一个统一的API接口可以使得你的PHP应用不去关心具体要 连接的数据库服务器系统类型。也就是说,如果你使用PDO的API,可以在任何需要的时候无缝切换数据库服务器,比如从Firebird 到MySQL,仅仅需要修改很少的PHP代码。
当然,PDO也有它自己的先进性,比如一个干净的,简单的,可移植的API,它最主要的缺点是会限制让你不能使用 后期MySQL服务端提供所有的数据库高级特性。比如,PDO不允许使用MySQL支持的多语句执行。
PDO的MySQL驱动并不是一套API,至少从PHP程序员的角度来看是这样的。实际上,PDO的MySQL驱动处于PDO自己的下层, 提供了特定的Mysql功能。程序员直接调用PDO的API,而PDO使用了PDO的MySQL驱动完成与MySQL服务器端的交互。
PDO的MySQL驱动是众多PDO驱动中的一个。其他可用的PDO驱动包括Firebird,PostgreSQL等等。

PDO {

__construct (string$dsn [, string$username [, string$password [,array$driver_options ]]] )
bool beginTransaction ( void )
bool commit ( void )
mixed errorCode ( void )
array errorInfo ( void )
int exec ( string $statement )
mixed getAttribute ( int $attribute )
array getAvailableDrivers ( void )
bool inTransaction ( void )
string lastInsertId ([ string$name =NULL ] )
PDOStatementprepare (string$statement [,array$driver_options = array() ] )
PDOStatementquery (string$statement )
string quote ( string $string [, int $parameter_type = PDO::PARAM_STR ] )
bool rollBack ( void )
bool setAttribute ( int $attribute , mixed$value )
}

Table of Contents
PDO::beginTransaction — Initiates a transaction
PDO::commit — Commits a transaction
PDO::__construct — Creates a PDO instance representing a connection to a database
PDO::errorCode — Fetch the SQLSTATE associated with the last operation on the database handle
PDO::errorInfo — Fetch extended error information associated with the last operation on the database handle
PDO::exec — Execute an SQL statement and return the number of affected rows
PDO::getAttribute — Retrieve a database connection attribute
PDO::getAvailableDrivers — Return an array of available PDO drivers
PDO::inTransaction — Checks if inside a transaction
PDO::lastInsertId — Returns the ID of the last inserted row or sequence value
PDO::prepare — Prepares a statement for execution and returns a statement object
PDO::query — Executes an SQL statement, returning a result set as a PDOStatement object
PDO::quote — Quotes a string for use in a query.
PDO::rollBack — Rolls back a transaction
PDO::setAttribute — Set an attribute

php基础系列:PHP连接MySQL数据库用到的三种API的更多相关文章

  1. Java基础93 JDBC连接MySQL数据库

    本文知识点(目录): 1.什么是jdbc     2.jdbc接口的核心API     3.使用JDBC技术连接MySQL数据库的方法    4.使用Statement执行sql语句(DDL.DML. ...

  2. php基础编程-php连接mysql数据库-mysqli的简单使用

    很多php小白在学习完php基础后,或多或少要接触到数据库的使用.而mysql数据库是你最好的选择,本文就mysql来为大家介绍php如何连接到数据库. PHP MySQLi = PHP MySQL ...

  3. 助手系列之连接mysql数据库

    import MySQLdbdef main(): try: conn=MySQLdb.connect(host='127.0.0.1',user='root',passwd='pass',db='a ...

  4. Ruby 连接MySQL数据库

    使用Ruby连接数据库的过程还真的是坎坷,于是写点文字记录一下. 简介 Ruby简介 RubyGems简介 包管理之道 比较著名的包管理举例 细说gem 常用的命令 准备 驱动下载 dbi mysql ...

  5. Spring Boot连接MySQL数据库

    上篇 只需两步!Eclipse+Maven快速构建第一个Spring Boot项目 已经构建了一个Spring Boot项目,本文在此基础上进行连接MySQL数据库的操作. 1. pom.xml添加依 ...

  6. JDBC连接MySQL数据库基础

    主要内容 MySQL的基本操作和基本SQL语法 使用JDBC进行MySQL数据库的开发 使用DriverManager.Connection.PreparedStatement.ResultSet对数 ...

  7. ava基础MySQL存储过程 Java基础 JDBC连接MySQL数据库

    1.MySQL存储过程   1.1.什么是存储过程 带有逻辑的sql语句:带有流程控制语句(if  while)等等 的sql语句   1.2.存储过程的特点 1)执行效率非常快,存储过程是数据库的服 ...

  8. java web 程序---jsp连接mysql数据库的实例基础+表格显示

    <%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="g ...

  9. java jdbc 连接mysql数据库 实现增删改查

    好久没有写博文了,写个简单的东西热热身,分享给大家. jdbc相信大家都不陌生,只要是个搞java的,最初接触j2ee的时候都是要学习这么个东西的,谁叫程序得和数据库打交道呢!而jdbc就是和数据库打 ...

随机推荐

  1. web桌面程序之图标拖动排序的分析

    在web桌面程序里,图标拖动并重新排序是个比较常见的功能.这个功能我之前反复修改了好几遍,现在终于整理出了比较理想的解决思路,决定拿出来分享下. 这一功能主要有哪些难点呢?我总结了一下一共有2处难点: ...

  2. toastr 自定义提示

    在线实例 实例演示 使用方法 <button type="button" class="btn btn-primary" id="showtoa ...

  3. nodejs--实现跨域抓取数据

    最近公司安排给我一个任务,抓取页面数据:http://survey.finance.sina.com.cn/static/20205/20131120.html?pid=20205&dpc=1 ...

  4. 详细解读XMLHttpRequest(二)响应属性、二进制数据、监测上传下载进度

    本文主要参考:MDN 分析并操作 responseXML属性 如果你使用 XMLHttpRequest 来获得一个远程的 XML 文档的内容,responseXML 属性将会是一个由 XML 文档解析 ...

  5. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q81-Q83)

    Question  81You are designing a custom administrative timer job for a SharePoint 2010 farm. You need ...

  6. iOS 三方库fmdb 的使用

    使用fmdb 做本地数据的存储非常方便, 1. github 上搜索fmdb 下载压缩包 导入到工程中 (如果你的mac 有cocoapod 也可以直接通过cocoapod 添加) 2. 以下代码是通 ...

  7. android Activity runOnUiThread() 方法使用

    在android 中我们一般用 Handler 做主线程 和 子线程 之间的通信 . 现在有了一种更为简洁的写法,就是 Activity 里面的 runOnUiThread( Runnable )方法 ...

  8. android 浅谈Aidl 通讯机制

    服务端: 首先是编写一个aidl文件,注意AIDL只支持方法,不能定义静态成员,并且方法也不能有类似public等的修饰符:AIDL运行方法有任何类型的参数和返回值,在java的类型中,以下的类型使用 ...

  9. 从零开始一个iOS项目(一)——基本准备以及cocopods的安装

    项目开发分为:独立开发和迭代开发,我主要讲独立开发,若读者是迭代开发,希望公司的代码一定要规范,便能省去许多麻烦,也能从中获益,闲时也可接些外包,赚一些外快,也是美差,然而独立开发最能锻炼人的能力. ...

  10. php多文件上传数组 转换

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta ...