1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP Developer''''s Dictionary- P89 pptx

5 186 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 365,13 KB

Nội dung

PHP Developer’s Dictionary IT-SC book 440 int msql_pconnect (string hostname [, string hostname[:port] [, string username [, string password ]]]]) Description The msql_pconnect() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, opens a persistent connection to an mSQL database and returns the link identifier on success and returns FALSE otherwise. The function tries to find an existing persistent connection and return its handle instead of opening a new connection, if possible. Also, the connection will not be closed with the end of a script's processing or by calling the msql_close() command. msql_query() Syntax int msql_query (string query , int link_identifier ) Description The msql_query() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, sends the query to the server associated with the specified link_identifier . If no link_identifier is specified, the last opened link is used. If no links are open, a connection attempt is made as if msql_connect() were called. The return value is a link identifier on success and FALSE otherwise. msql_regcase() Syntax string msql_regcase (string string) Description The msql_regcase() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, makes a regular expression for a case-insensitive match. The return value will be a valid regular expression that matches string . The resulting expression is string with each character converted to a bracket expression. msql_result() PHP Developer’s Dictionary IT-SC book 441 Syntax int msql_result (int query_identifier, int i, mixed field) Description The msql_result() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, returns the contents of the cell at the row specified by the i parameter in the corresponding field . The field parameter can be the field name, field's offset, or the table name dot field name (tablename.fieldname). In the case where a column alias is used, use it instead of the column name. When dealing with large result sets, it is more efficient to fetch a row at a time, than to fetch individual cells. Also, using offsets has better performance than using names. msql_select_db() Syntax int msql_select_db (string database_name, int link_identifier) Description The msql_select_db() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, sets the current active database_name for the connection referenced by the link_identifier parameter. If no link is specified, the last open link is used; if no link is available, the function attempts to establish a new one. The return value is TRUE on success and FALSE otherwise. msql_selectdb() Syntax int msql_selectdb (string database_name, int link_identifier) Description The msql_selectdb() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, is identical to msql_selectdb() . msql_tablename() PHP Developer’s Dictionary IT-SC book 442 Syntax string msql_tablename (int query_identifier, int field) Description The msql_tablename() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, uses the query_identifier returned by the msql_list_tables() function along with the field index and returns the corresponding table name for that field. The msql_numrows() function can be used to determine the number of tables in the result pointer. MySQL The MySQL functions enable you to access data in a MySQL database. More information can be found at http://www.mysql.com . To include MySQL support, use configure with the –-with-mysql=<path to mysql> . Specifying a path to mysql value is optional, but recommended if you are using different versions of PHP at the same time. The following example connects to the user database and retrieves user123's password from the users table: <? $mysql_link_id = mysql_connect("users"); $mysql_result_id = mysql_query ("select password from users where username=user123",$mysql_link_id); $results = mysql_fetch_row(mysql_result_id); echo $results[0]; mysql_close($mysql_link_id); ?> mysql_affected_rows() Syntax int mysql_affected_rows ([int link_identifier]) Description The mysql_affected_rows() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, returns the number of rows affected by the previous MySQL operation (insert, update, or delete) performed on the link_identifier . The last open link is assumed if no link_identifier is specified. If the previous PHP Developer’s Dictionary IT-SC book 443 statement was a delete with no where clause (all rows deleted), the return value will be 0 . For select statements, you should use the mysql_num_rows() function to see how many rows were returned. Also note that when performing an update statement, if the result is that no rows change even though they meet the where clause criteria, the return value will be 0. The following example opens the user table in the users database and retrieves user123's password: <? $mysql_db = mysql_connect ("users"); $mysql_result_id = mysql_query ("users","select password where username='user123'",mysql_db); $mysql_row = mysql_fetch_row($mysql_result_id); echo mysql_row[0]; mysql_close ($mysql_db); ?> mysql_change_user() Syntax int mysql_change_user (string user , string password , [, string database [, int link_identifier ]]) Description The mysql_change_user() function, which is available from PHP 3.0.13 to PHP 3.0.16, changes the logged-in user of the active connection to the parameter values specified using the link_identifier connection, or the current connection if none is specified. If the function fails, the currently connected user maintains his connection. mysql_close() Syntax int mysql_close ([int link_identifier ]) Description The mysql_close() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, closes the connection referenced by the link_identifier parameter, or the last opened link if none is specified. Closing a link occurs automatically at the end of a script's processing, so this function isn't normally used. PHP Developer’s Dictionary IT-SC book 444 mysql_connect() Syntax int mysql_connect ([string hostname [:port] [:/path/to/socket ] [, string username [, string password]]]) Description The mysql_connect() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, returns a link identifier on establishment of a connection and FALSE on failure. The host:port parameter defaults to 'localhost:3306' , and username defaults to the owner of the server process, and password defaults to an empty string. The hostname parameter can also include a port or a path/to/socket for the local host. A subsequent identical call to this function will cause an existing link to be returned if available. Also, the link will be closed automatically when a script completes its processing unless it is explicitly closed using the msql_close() function. mysql_create_db() Syntax int mysql_create_db (string database_name [, int link_identifier]) Description The mysql_create_db() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, attempts to create a new database named database_name on the server referenced by the link_identifier . Note that for backward compatibility, mysql_createdb() can also be used. mysql_data_seek() Syntax int mysql_data_seek_ (int result_identifier, int row_number) Description . msql_selectdb() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, is identical to msql_selectdb() . msql_tablename() PHP Developer’s Dictionary IT-SC book 442 Syntax. link_identifier ) Description The msql_query() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, sends the query to the server associated with the specified. string) Description The msql_regcase() function, which is available from PHP 3.0 to PHP 3.0.16 along with PHP 4.0 and higher, makes a regular expression for a case-insensitive match. The

Ngày đăng: 07/07/2014, 05:20

TỪ KHÓA LIÊN QUAN