MySQL and PHP.pdf
(
2912 KB
)
Pobierz
MySQL and PHP
Abstract
This manual describes the PHP extensions and interfaces that can be used with MySQL.
For legal information, see the
Legal Notices.
For help with using MySQL, please visit either the
MySQL Forums
or
MySQL Mailing Lists,
where you can discuss
your issues with other MySQL users.
For additional documentation on MySQL products, including translations of the documentation into other languages,
and downloadable versions in variety of formats, including HTML and PDF formats, see the
MySQL Documentation
Library.
Document generated on: 2016-08-02 (revision: 48430)
Table of Contents
Preface and Legal Notices ............................................................................................................... xiii
1 Introduction to the MySQL PHP API ................................................................................................ 1
2 Overview of the MySQL PHP drivers ............................................................................................... 3
2.1 Introduction .......................................................................................................................... 3
2.2 Terminology overview ........................................................................................................... 3
2.3 Choosing an API .................................................................................................................. 4
2.4 Choosing a library ................................................................................................................ 6
2.5 Concepts .............................................................................................................................. 7
2.5.1 Buffered and Unbuffered queries ................................................................................ 7
2.5.2 Character sets ........................................................................................................... 9
3 MySQL Improved Extension ........................................................................................................... 11
3.1 Overview ............................................................................................................................ 14
3.2 Quick start guide ................................................................................................................ 18
3.2.1 Dual procedural and object-oriented interface ............................................................ 18
3.2.2 Connections ............................................................................................................. 20
3.2.3 Executing statements ............................................................................................... 22
3.2.4 Prepared Statements ............................................................................................... 26
3.2.5 Stored Procedures ................................................................................................... 33
3.2.6 Multiple Statements ................................................................................................. 38
3.2.7 API support for transactions ..................................................................................... 39
3.2.8 Metadata ................................................................................................................. 40
3.3 Installing/Configuring ........................................................................................................... 42
3.3.1 Requirements .......................................................................................................... 42
3.3.2 Installation ............................................................................................................... 42
3.3.3 Runtime Configuration .............................................................................................. 44
3.3.4 Resource Types ...................................................................................................... 46
3.4 The mysqli Extension and Persistent Connections ................................................................ 46
3.5 Predefined Constants ......................................................................................................... 47
3.6 Notes ................................................................................................................................. 50
3.7 The MySQLi Extension Function Summary .......................................................................... 51
3.8 Examples ........................................................................................................................... 57
3.8.1 MySQLi extension basic examples ........................................................................... 57
3.9 The mysqli class ................................................................................................................ 59
3.9.1
mysqli::$affected_rows, mysqli_affected_rows
......................................... 62
3.9.2
mysqli::autocommit, mysqli_autocommit
....................................................... 65
3.9.3
mysqli::begin_transaction, mysqli_begin_transaction
........................... 66
3.9.4
mysqli::change_user, mysqli_change_user
................................................... 68
3.9.5
mysqli::character_set_name, mysqli_character_set_name
....................... 71
3.9.6
mysqli::$client_info, mysqli_get_client_info
......................................... 72
3.9.7
mysqli::$client_version, mysqli_get_client_version
............................. 73
3.9.8
mysqli::close, mysqli_close
........................................................................... 74
3.9.9
mysqli::commit, mysqli_commit
....................................................................... 75
3.9.10
mysqli::$connect_errno, mysqli_connect_errno
....................................... 77
3.9.11
mysqli::$connect_error, mysqli_connect_error
....................................... 78
3.9.12
mysqli::__construct, mysqli_connect
......................................................... 80
3.9.13
mysqli::debug, mysqli_debug
......................................................................... 83
3.9.14
mysqli::dump_debug_info, mysqli_dump_debug_info
.................................. 84
3.9.15
mysqli::$errno, mysqli_errno
....................................................................... 85
3.9.16
mysqli::$error_list, mysqli_error_list
................................................... 87
3.9.17
mysqli::$error, mysqli_error
....................................................................... 88
3.9.18
mysqli::$field_count, mysqli_field_count
............................................... 90
iii
MySQL and PHP
3.9.19
mysqli::get_charset, mysqli_get_charset
................................................. 92
3.9.20
mysqli::get_client_info, mysqli_get_client_info
.................................. 93
3.9.21
mysqli_get_client_stats
............................................................................... 94
3.9.22
mysqli_get_client_version, mysqli::$client_version
............................ 97
3.9.23
mysqli::get_connection_stats, mysqli_get_connection_stats
.............. 97
3.9.24
mysqli::$host_info, mysqli_get_host_info
.............................................. 100
3.9.25
mysqli::$protocol_version, mysqli_get_proto_info
.............................. 102
3.9.26
mysqli::$server_info, mysqli_get_server_info
...................................... 103
3.9.27
mysqli::$server_version, mysqli_get_server_version
.......................... 105
3.9.28
mysqli::get_warnings, mysqli_get_warnings
............................................ 106
3.9.29
mysqli::$info, mysqli_info
......................................................................... 107
3.9.30
mysqli::init, mysqli_init
........................................................................... 108
3.9.31
mysqli::$insert_id, mysqli_insert_id
...................................................... 109
3.9.32
mysqli::kill, mysqli_kill
........................................................................... 111
3.9.33
mysqli::more_results, mysqli_more_results
............................................ 113
3.9.34
mysqli::multi_query, mysqli_multi_query
................................................ 114
3.9.35
mysqli::next_result, mysqli_next_result
................................................ 116
3.9.36
mysqli::options, mysqli_options
............................................................... 117
3.9.37
mysqli::ping, mysqli_ping
........................................................................... 118
3.9.38
mysqli::poll, mysqli_poll
........................................................................... 120
3.9.39
mysqli::prepare, mysqli_prepare
............................................................... 122
3.9.40
mysqli::query, mysqli_query
....................................................................... 124
3.9.41
mysqli::real_connect, mysqli_real_connect
............................................ 127
3.9.42
mysqli::real_escape_string, mysqli_real_escape_string
.................... 131
3.9.43
mysqli::real_query, mysqli_real_query
.................................................... 134
3.9.44
mysqli::reap_async_query, mysqli_reap_async_query
............................ 134
3.9.45
mysqli::refresh, mysqli_refresh
............................................................... 135
3.9.46
mysqli::release_savepoint, mysqli_release_savepoint
........................ 136
3.9.47
mysqli::rollback, mysqli_rollback
........................................................... 136
3.9.48
mysqli::rpl_query_type, mysqli_rpl_query_type
.................................... 139
3.9.49
mysqli::savepoint, mysqli_savepoint
........................................................ 140
3.9.50
mysqli::select_db, mysqli_select_db
........................................................ 140
3.9.51
mysqli::send_query, mysqli_send_query
.................................................... 142
3.9.52
mysqli::set_charset, mysqli_set_charset
................................................ 143
3.9.53
mysqli::set_local_infile_default,
mysqli_set_local_infile_default
........................................................................ 145
3.9.54
mysqli::set_local_infile_handler,
mysqli_set_local_infile_handler
........................................................................ 145
3.9.55
mysqli::$sqlstate, mysqli_sqlstate
......................................................... 148
3.9.56
mysqli::ssl_set, mysqli_ssl_set
............................................................... 150
3.9.57
mysqli::stat, mysqli_stat
........................................................................... 151
3.9.58
mysqli::stmt_init, mysqli_stmt_init
........................................................ 152
3.9.59
mysqli::store_result, mysqli_store_result
............................................ 153
3.9.60
mysqli::$thread_id, mysqli_thread_id
...................................................... 154
3.9.61
mysqli::thread_safe, mysqli_thread_safe
................................................ 156
3.9.62
mysqli::use_result, mysqli_use_result
.................................................... 156
3.9.63
mysqli::$warning_count, mysqli_warning_count
...................................... 159
3.10 The mysqli_stmt class ..................................................................................................... 161
3.10.1
mysqli_stmt::$affected_rows, mysqli_stmt_affected_rows
.................. 162
3.10.2
mysqli_stmt::attr_get, mysqli_stmt_attr_get
........................................ 164
3.10.3
mysqli_stmt::attr_set, mysqli_stmt_attr_set
........................................ 165
3.10.4
mysqli_stmt::bind_param, mysqli_stmt_bind_param
................................ 166
3.10.5
mysqli_stmt::bind_result, mysqli_stmt_bind_result
............................ 169
3.10.6
mysqli_stmt::close, mysqli_stmt_close
.................................................... 171
iv
MySQL and PHP
3.11
3.12
3.13
3.14
3.15
3.10.7
mysqli_stmt::__construct
...........................................................................
3.10.8
mysqli_stmt::data_seek, mysqli_stmt_data_seek
....................................
3.10.9
mysqli_stmt::$errno, mysqli_stmt_errno
..................................................
3.10.10
mysqli_stmt::$error_list, mysqli_stmt_error_list
............................
3.10.11
mysqli_stmt::$error, mysqli_stmt_error
................................................
3.10.12
mysqli_stmt::execute, mysqli_stmt_execute
..........................................
3.10.13
mysqli_stmt::fetch, mysqli_stmt_fetch
..................................................
3.10.14
mysqli_stmt::$field_count, mysqli_stmt_field_count
........................
3.10.15
mysqli_stmt::free_result, mysqli_stmt_free_result
..........................
3.10.16
mysqli_stmt::get_result, mysqli_stmt_get_result
..............................
3.10.17
mysqli_stmt::get_warnings, mysqli_stmt_get_warnings
......................
3.10.18
mysqli_stmt::$insert_id, mysqli_stmt_insert_id
................................
3.10.19
mysqli_stmt::more_results, mysqli_stmt_more_results
......................
3.10.20
mysqli_stmt::next_result, mysqli_stmt_next_result
..........................
3.10.21
mysqli_stmt::$num_rows, mysqli_stmt_num_rows
....................................
3.10.22
mysqli_stmt::$param_count, mysqli_stmt_param_count
........................
3.10.23
mysqli_stmt::prepare, mysqli_stmt_prepare
..........................................
3.10.24
mysqli_stmt::reset, mysqli_stmt_reset
..................................................
3.10.25
mysqli_stmt::result_metadata, mysqli_stmt_result_metadata
..........
3.10.26
mysqli_stmt::send_long_data, mysqli_stmt_send_long_data
..............
3.10.27
mysqli_stmt::$sqlstate, mysqli_stmt_sqlstate
....................................
3.10.28
mysqli_stmt::store_result, mysqli_stmt_store_result
......................
The mysqli_result class ...................................................................................................
3.11.1
mysqli_result::$current_field, mysqli_field_tell
..............................
3.11.2
mysqli_result::data_seek, mysqli_data_seek
..........................................
3.11.3
mysqli_result::fetch_all, mysqli_fetch_all
..........................................
3.11.4
mysqli_result::fetch_array, mysqli_fetch_array
..................................
3.11.5
mysqli_result::fetch_assoc, mysqli_fetch_assoc
..................................
3.11.6
mysqli_result::fetch_field_direct, mysqli_fetch_field_direct
......
3.11.7
mysqli_result::fetch_field, mysqli_fetch_field
..................................
3.11.8
mysqli_result::fetch_fields, mysqli_fetch_fields
..............................
3.11.9
mysqli_result::fetch_object, mysqli_fetch_object
..............................
3.11.10
mysqli_result::fetch_row, mysqli_fetch_row
........................................
3.11.11
mysqli_result::$field_count, mysqli_num_fields
................................
3.11.12
mysqli_result::field_seek, mysqli_field_seek
....................................
3.11.13
mysqli_result::free, mysqli_free_result
..............................................
3.11.14
mysqli_result::$lengths, mysqli_fetch_lengths
..................................
3.11.15
mysqli_result::$num_rows, mysqli_num_rows
..........................................
The mysqli_driver class ...................................................................................................
3.12.1
mysqli_driver::embedded_server_end, mysqli_embedded_server_end
..
3.12.2
mysqli_driver::embedded_server_start,
mysqli_embedded_server_start
..............................................................................
3.12.3
mysqli_driver::$report_mode, mysqli_report
..........................................
The mysqli_warning class ...............................................................................................
3.13.1
mysqli_warning::__construct
......................................................................
3.13.2
mysqli_warning::next
...................................................................................
The mysqli_sql_exception class .......................................................................................
Aliases and deprecated Mysqli Functions .........................................................................
3.15.1
mysqli_bind_param
.........................................................................................
3.15.2
mysqli_bind_result
.......................................................................................
3.15.3
mysqli_client_encoding
...............................................................................
3.15.4
mysqli_connect
...............................................................................................
3.15.5
mysqli::disable_reads_from_master,
mysqli_disable_reads_from_master
......................................................................
172
172
175
177
179
181
184
186
186
187
189
190
190
191
192
194
195
198
199
201
202
204
207
208
210
212
213
215
218
221
223
226
229
231
232
234
235
237
239
240
240
241
243
244
244
244
245
245
245
246
246
247
v
Plik z chomika:
musli_com
Inne pliki z tego folderu:
The Hackademy Prog - Apprendre A Programmer En PHP.pdf
(34947 KB)
Apress.Professional.PHP4.PROPER.eBook-LiB.chm
(12608 KB)
John.Wiley.and.Sons.PHP5.and.MySQL.Bible.Apr.2004.eBook-DDU.pdf
(16849 KB)
Manuel PHP FR.pdf
(11855 KB)
Développer une application avec PHP et MySQL.pdf
(4444 KB)
Inne foldery tego chomika:
Apache
Artisteer
Javascript Ebook Collection
Joomla
jQuery
Zgłoś jeśli
naruszono regulamin