ADODB数据库抽象层操作

/****************by Jiangong SUN************/

<?php


//include file
include("adodb5/adodb.inc.php");
include("adodb5/adodb-pager.inc.php");
//set variables
$server = 'localhost';
$user = 'charles';
$password = 'charles';
$database = 'test';
//create a new connection
$db = ADONewConnection("mysql");
//start debug
$db -> debug = true;
//persistent connection to mysql db
$db -> PConnect($server, $user, $password, $database);
//sql query
$sql = "select idd, date_enreg from contrat where idd=440636";
//execute
$rs = $db->Execute($sql);
//get the result set
foreach($rs as $k => $row){
    echo $row[0].'<br />';
}

//insert a new line
$sql2 = "select date_enreg from contrat";
$rs2 = $db->Execute($sql2);
$record2 = array();
$record2['idd'] = '1011';
$record2['date_enreg'] = '11/11/2005';
$insertSQL = $db->GetInsertSQL($rs2, $record2);
$db->Execute($insertSQL);

//update an existent line
$sql3 = "select date_enreg from contrat where idd = 6605";
$rs3 = $db->Execute($sql3);
$record3 = array();
$record3['date_enreg'] = '01/01/2007';
$updateSQL = $db->GetUpdateSQL($rs3, $record3);
$db->Execute($updateSQL);

//separate the records by pages
$sql4 = "select date_enreg from contrat";
$pager = new ADODB_Pager($db, $sql4);
$pager->Render($rows_per_page=5);

//close connection
$db->close();

?>

 

资源:

http://adodb.sourceforge.net/#download
http://phplens.com/lens/adodb/docs-adodb.htm#scr

你可能感兴趣的:(sql,sql,sql,数据库,Date,Date,Date,database,database,database,variables)