Copy the code The code is as follows:
$DB_PASS part”; DEBUG test, the default value is false$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;//Returned recordset form, associated form
/***
Returned recordset form
define('ADODB_FETCH_DEFAULT',0);
define('ADODB_FETCH_NUM ', 1); fDefine (' Adodb_fetch_assoc ', 2);
Define (' Adodb_fetch_both ', 3);
The above constant, is defined in adodb.inc.php, that is, you can use "$ adodb_fetch_mode = 2 "Method 方式ADODB_FETCH_NUM The index in the record set returned is in numeric form, that is, the sort order value of the database field
ADODB_FETCH_ASSOC The index in the record set returned is the original database field name
ADODB_FETCH_BOTH and ADODB_FETCH_DEFAULT return the above two at the same time.Some databases do not support
An example:
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rs1 = $db->Execute('select * from table');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs2 = $db->Execute ('Select*from table');
Print_r ($ RS1- & GT; Fields);#The array returned is: array ([0] = & gt; 'v0', [1] = & gt; 'v1')
print_r. ($rs2->fields); # The returned array is: array(['col1']=>'v0',['col2'] =>'v1') Database, methods include Connect, PConnect, NConnect, generally use Connect
if (!@$db->Connect("$DB_HOST", "$DB_USER", "$DB_PASS", "$DB_DATABASE")) { exit( 'The server is busy, please visit again later'); ($sql), execute the $sql statement in the parameters
SelectLimit($sql,$numrows=-1,$offset=-1) $numrows: how many records are taken, $offset, which record to start from, usually Used for paging, or when only fetching a few records
*/
//Example: Fetching multiple records
$sql = "Select * FROM table orDER BY id DESC";
if (!$rs = $db- & gt; Execute ($ SQL)) {// execute the SQL statement, and return the result to the $ RS variable
echo $ db- & gt; errormsg (); // ;//Close the database ; ';
// using use with using out out out out outmbps outmbps out out Over’s’ to be's to be Point to the next record, otherwise an infinite loop will occur!
}& $ Rs- & gt; close (); // Close to release memory
// Insert new records
$ SQL = "Insert Table (user_type, username) (3, 'liucheng')" "";
$ db- & gt; Execute($sql); having
$sql = " Delete FROM table Where id=2"; $db-> Array, error returns false using
echo 'I didn't find this record';
exit ();
} Else {
echo $ data_ary ['username']. ''. $ data_ary ['password']. ''. $ data_ary ['user_type']. '.
';
} . sql ; result = $rs->FetchRow()) {
echo 'This record was not found'; '< ;br>';
//Get a single field
//$db->GetOne($sql) Get the value of the first field of the first record, return false if an error occurs
$sql = "Select COUNT(id) FROM table";
$record_nums = $db->GetOne($sql); b->GetOne( $sql);
echo $result;//Print out the value of username
/*
When adding, modifying, or deleting records,
Use $db->qstr() for string fields The characters entered by the user are processed.
For numeric fields, data judgment is required
Update records. Note: This is for the case where magic_quotes is set to Off in php.ini. If you are not sure, you can use
$db-> ;qstr($content,get_magic_quotes_gpc())
Note: c
*/
$sql = "Update table SET c
$db->Execute($sql);
/*$db- >Insert_ID() , no parameters, returns the ID value of the record just inserted, only supports some databases, databases with auto-increment function, such as PostgreSQL, MySQL and MS SQL
*/
//Example:
$sql = "Insert table (user_type,username) VALUES (3, 'liucheng')"; "
$db->Execute($sql); "
/*$db ->GenID($seqName = 'adodbseq',$startID=1), generates an ID value. $seqName: the database table name used to generate this ID, $startID: the starting value, generally does not need to be set, it will The value in $seqName is automatically increased by 1. Supports some databases, some databases do not support
Insert_ID, GenID. Generally, I use GenID. The purpose of using it is to get its ID immediately after inserting the record.
*** -& gt; Genid ('user_id_seq');
$ SQL = "Insert Table (ID, User_type, Username) Values (". $ User_id. ", 3, 'LiuCheng')");
$ db-& gt; e XECUTE ($ sql);*/*
$ rs- & gt; recordcount (), the total number of record sets is taken out, no parameter
It seems to be the method of using the recording of the draw, the number of data in the array of the count () array, if you take a lot of data, if you take a lot of data , the efficiency is relatively slow. It is recommended to use the COUNT(*) method in SQL.
*/
$sql = "Select * FROM table orDER BY id DESC";
if (!$rs = $db->Execute($sql)) { echo $db->ErrorMsg( ); db->Close();
$record_nums = $rs->RecordCount();
/*
If you want to perform the same loop processing twice on a certain result set, you can use the following method
The following is just an example, just to illustrate $rs ->How to use MoveFirst()
*/
$sql = "Select * FROM table orDER BY id DESC";
if (!$rs = $db->Execute($sql)) {
echo $db ->ErrorMsg(); ->EOF) { $ RS-& GT; Fields ['Username']
Echo $ RS- & GT; Fields ['Username']. '& LT; Br & GT; // Print_r ($ RS- & GT; Fields) Try, $ RS- & G T ;fields['Field name'], returns the value in this field ; = array_unique($username_ary); ; '] . '
';//print_r($rs->fields) try, $rs->fields['field name'], what is returned is the value in this field
$rs-> ;MoveNext(); // Point the pointer to the next record ; ;
?>
The above has introduced a collection of commonly used php ADODB usage methods for dob, including dob content. I hope it will be helpful to friends who are interested in PHP tutorials.