Tuesday, May 8, 2012

Mysql Functions for PHP

0 comments

Mysql function for php….
Mysql_connect : This function is used to create a Non-Persistence connection for database.
By using this connection we have the separate connection for all pages.

Mysql_pconnect : This function is used to create a Persistence connection for database.
By using this connection we have the one connection for all pages. We need not to write the connection code at all pages. But in this type of connect we don't close the connection.

Mysql_close : This function is use to close the connection from the database.
MYSQL_SELECT_DB : This function is use to select the database in the list for database.


Methods For data fetching from database :-
MYSQL_FETCH_ARRAY : This function is used to fetch the recordset in a NUMERIC and ASSOCIATIVE ARRAY. In this result we fetch the data from 2 method.
  • By numeric method. Ex.. $a[' 0']; This will gave us the value of ZERO index.
  • By associate name method. Ex.. $a[' name']; This will gave us the value of NAME field.

MYSQL_FETCH_ASSOC : This function is used to fetch the record set in ASSOCIATIVE ARRAY. In this result we fetch the data from using associate name method.

MYSQL_FETCH_ROW : This function is used to fetch the record set in a NUMERIC ARRAY. In this result we fetch the data from numeric method.

MYSQL_FETCH_OBJECT : This function is used to fetch the record set in a OBJECT. In this result we fetch the data from object.

MYSQL_INSERT_ID : This function give the value of last inserted ID of auto Increment field.

MYSQL_NUM_ROWS : This function give us the number of rows in result set.

MYSQL_FETCH_FIELD : This function is used to fetch the name of field from database 
in a NUMERIC ARRAY. In this result we fetch the data from numeric method.

MYSQL_FIELD_TYPE : This function give the data type of the particular field. 
 
MYSQL_FIELD_LEN : This function give the Length of the particular field.