Php efficiently retrieves data by page. mysql. php retrieves records from the database. this is a summary of my personal experience and is for your reference only!
/**
* Basic functions of PHP + MYSQL databases
* Http://blog.csdn.net/yown
*/
######################################## ####
# Obtain the sequence ID
######################################## ####
Function getSequence (){
$ SQL = "update sequence set id = last_insert_id (id + 1 );";
$ Sql2 = "select last_insert_id ();";
If (mysql_num_rows ($ result) = 0 ){
Mysql_close ($ link );
Return "";
}
$ Myrow = mysql_fetch_row ($ result );
$ Ret = $ myrow [0];
Mysql_close ($ link );
Return $ ret;
}
######################################## ####
# Obtain the data in column N of the Nth record of strSql. the subscript starts from 1.
######################################## ####
Function getData ($ strsql, $ row, $ col ){
Global $ dbuser, $ dbpass, $ host, $ database, $ printsql;
$ Link = mysql_connect ($ host, $ dbuser, $ dbpass );
If (! $ Link ){
Return mysql_error ();
}
If (mysql_num_rows ($ result) = 0 ){
Mysql_close ($ link );
Return "";
}
$ I = 0;
While ($ myrow = mysql_fetch_array ($ result )){
If ($ I = $ row-1 ){
$ Ret = $ myrow;
Break;
}
$ I = $ I + 1;
}
Mysql_close ($ link );
Return $ ret;
}
######################################## ####
# Getting strSql record set and saving it to the array
######################################## ####
Function getResultSetData ($ strsql ){
Global $ dbuser, $ dbpass, $ host, $ database, $ printsql;
$ Link = mysql_connect ($ host, $ dbuser, $ dbpass );
If (! $ Link ){
Return mysql_error ();
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.