& Nbsp; I downloaded adodb a few days ago and wanted to use adodb to connect to the access database. later, I connected the database, but I cannot update or insert records, I don't know why no one has answered the worried question yet. I gave up adodb and used my odbc in php, but it was inconvenient to use. I wrote the following functions, it has not been encapsulated into a class, so I hope to help my friends who have the same problem & lt ;? Php ** @ accessc downloaded adodb a few days ago and wanted to use adodb to connect to the access database. later, the access database was connected, but records cannot be updated or inserted, I don't know why no one has answered the worried question yet. I gave up adodb and used my odbc in php, but it was inconvenient to use. I wrote the following functions, it has not been encapsulated into a class, so I hope to help my friends who have the same problem
/*
* @ Access class
* Insert, update, delete record
* Version 1.0
* Date 2005.6
* Power by Samsun manzaro (34n pig)
* Www.cncms.com
*/
// ==============================================
// Insert record
// Insert record
// ==============================================
Function insRd ($ table, $ field ){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ TmpA = explode (',', $ field );
$ Ins = '';
For ($ I = 0; $ I $ Ins. = "'". $ _ POST [$ tmpA [$ I]. "',";
}
$ Ins = substr ($ ins, 0,-1 );
$ SQL = "INSERT INTO". $ table. "(". $ field. ") VALUES (". $ ins .")";
// Echo $ SQL; exit;
$ Query = @ odbc_do ($ connid, $ SQL );
}
// ==============================================
// Get one record detail
// Obtain the detailed information of the current record
// ==============================================
Function getInfo ($ table, $ field, $ id, $ colnum ){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "select * from". $ table. "where". $ field. "=". $ id;
$ Query = @ odbc_do ($ connid, $ SQL );
If (odbc_fetch_row ($ query )){
For ($ I = 0; $ I <$ colnum; $ I ++ ){
$ Info [$ I] = odbc_result ($ query, $ I + 1 );
}
}
Return $ info;
}
// ==============================================
// Get record list
// Obtain the record list
// ==============================================
Function getList ($ table, $ field, $ colnum, $ condition, $ sort = "order by id desc "){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "select * from". $ table. "". $ condition. "". $ sort;
$ Query = @ odbc_do ($ connid, $ SQL );
// Echo $ SQL ."
";
$ I = 0;
While (odbc_fetch_row ($ query )){
$ RdList [$ I] = getInfo ($ table, $ field, odbc_result ($ query, 1), $ colnum );
$ I ++;
}
Return $ rdList;
}
// ==============================================
// Get record list condition
// Obtain the record list
// ==============================================
Function getFieldList ($ table, $ field, $ fieldnum, $ condition = "", $ sort = ""){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "select". $ field. "from". $ table. "". $ condition. "". $ sort;
$ Query = @ odbc_do ($ connid, $ SQL );
// Echo $ SQL ."
";
$ I = 0;
While (odbc_fetch_row ($ query )){
For ($ j = 0; $ j <$ fieldnum; $ j ++ ){
$ Info [$ j] = odbc_result ($ query, $ j + 1 );
}
$ RdList [$ I] = $ info;
$ I ++;
}
Return $ rdList;
}
// ==============================================
// Update record
// Update records
// ==============================================
Function updateInfo ($ table, $ field, $ id, $ set ){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "update". $ table. "set". $ set. "where". $ field. "=". $ id;
$ Query = @ odbc_do ($ connid, $ SQL );
}
// ==============================================
// Record delete
// Delete a record
// ==============================================
Function delRd ($ table, $ field, $ id ){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "delete from". $ table. "where". $ field. "=". $ id;
$ Query = @ odbc_do ($ connid, $ SQL );
}
// ==============================================
// Record delete cat
// Delete record (condition)
// ==============================================
Function delOrRd ($ table, $ condition ){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "delete from". $ table. "where". $ condition;
$ Query = @ odbc_do ($ connid, $ SQL );
}
// ==============================================
// Count record
// Obtain the number of records
// ==============================================
Function countRd ($ table, $ condition = ""){
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = database/email. mdb ";
$ Connid = @ odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("database connection error! ");
$ SQL = "select count (*) as num from". $ table. "". $ condition;
$ Query = @ odbc_do ($ connid, $ SQL );
Odbc_fetch_row ($ query );
$ Num = odbc_result ($ query, 1 );
Return $ num;
}
?>