Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
PHP MYSQL Functions (0 Comments)
Admin: Posted Date: March 3, 2010

The MySQL functions allows you to access MySQL database servers. For the MySQL functions to be available, you must compile PHP with MySQL support. For compiling, use --with-mysql=DIR (the optional DIR points to the MySQL directory).

PHP MySQL Functions

PHP: indicates the earliest version of PHP that supports the function.

mysql_affected_rows()

Returns the number of affected rows in the previous MySQL operation

mysql_change_user()


Deprecated. Changes the user of the current MySQL connection

mysql_client_encoding()

Returns the name of the character set for the current connection

mysql_close()

Closes a non-persistent MySQL connection

mysql_connect()

Opens a non-persistent MySQL connection

mysql_create_db()

Deprecated. Creates a new MySQL database. Use mysql_query() instead

mysql_data_seek()

Moves the record pointer

mysql_db_name()

Returns a database name from a call to mysql_list_dbs()

mysql_db_query()

Deprecated. Sends a MySQL query. Use mysql_select_db() and mysql_query() instead

mysql_drop_db()

Deprecated. Deletes a MySQL database. Use mysql_query() instead

mysql_errno()

Returns the error number of the last MySQL operation

mysql_error()

Returns the error description of the last MySQL operation

mysql_escape_string()

Deprecated. Escapes a string for use in a mysql_query. Use mysql_real_escape_string() instead

mysql_fetch_array()


Returns a row from a recordset as an associative array and/or a numeric array

mysql_fetch_assoc()

Returns a row from a recordset as an associative array

mysql_fetch_field()

Returns column info from a recordset as an object

mysql_fetch_lengths()

Returns the length of the contents of each field in a result row

mysql_fetch_object()

Returns a row from a recordset as an object

mysql_fetch_row()

Returns a row from a recordset as a numeric array

mysql_field_flags()

Returns the flags associated with a field in a recordset

mysql_field_len()

Returns the maximum length of a field in a recordset

mysql_field_name()

Returns the name of a field in a recordset

mysql_field_seek()

Moves the result pointer to a specified field

mysql_field_table()

Returns the name of the table the specified field is in

mysql_field_type()

Returns the type of a field in a recordset

mysql_free_result()

Free result memory

mysql_get_client_info()

Returns MySQL client info

mysql_get_host_info()

Returns MySQL host info

mysql_get_proto_info()

Returns MySQL protocol info

mysql_get_server_info()

Returns MySQL server info

mysql_info()

Returns information about the last query

mysql_insert_id()

Returns the AUTO_INCREMENT ID generated from the previous INSERT operation


mysql_list_dbs()

Lists available databases on a MySQL server

mysql_list_fields()

Deprecated. Lists MySQL table fields. Use mysql_query() instead

mysql_list_processes()

Lists MySQL processes

mysql_list_tables()


Deprecated. Lists tables in a MySQL database. Use mysql_query() instead

mysql_num_fields()


Returns the number of fields in a recordset

mysql_num_rows()

Returns the number of rows in a recordset

mysql_pconnect()

Opens a persistent MySQL connection

mysql_ping()

Pings a server connection or reconnects if there is no connection

mysql_query()

Executes a query on a MySQL database

mysql_real_escape_string()

Escapes a string for use in SQL statements

mysql_result()

Returns the value of a field in a recordset

mysql_select_db()

Sets the active MySQL database

mysql_stat()

Returns the current system status of the MySQL server

mysql_tablename()

Deprecated. Returns the table name of field. Use mysql_query() instead

mysql_thread_id()

Returns the current thread ID

mysql_unbuffered_query()

Executes a query on a MySQL database (without fetching / buffering the result)

PHP MySQL Constants

Since PHP 4.3 it has been possible to specify additional flags for the mysql_connect() and mysql_pconnect() functions:

PHP: indicates the earliest version of PHP that supports the constant.

Constant Description PHP
MYSQL_CLIENT_COMPRESS Use compression protocol 4.3
MYSQL_CLIENT_IGNORE_SPACE Allow space after function names 4.3
MYSQL_CLIENT_INTERACTIVE Allow interactive timeout seconds of inactivity before closing the connection 4.3
MYSQL_CLIENT_SSL Use SSL encryption (only available with version 4+ of the MySQL client library) 4.3

The mysql_fetch_array() function uses a constant for the different types of result arrays. The following constants are defined:

Constant Description PHP
MYSQL_ASSOC Columns are returned into the array with the fieldname as the array index  
MYSQL_BOTH Columns are returned into the array having both a numerical index and the fieldname as the array index  
MYSQL_NUM Columns are returned into the array having a numerical index (index starts at 0)  



 

 

 

 

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: