I downloaded adodb a few days ago and wanted to use it 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 title yet. I gave up adodb and applied my odbc in php,
I downloaded adodb a few days ago and wanted to use it 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 title yet. I gave up adodb and applied my own odbc in php, but the application was inconvenient. I wrote the following functions, it has not been encapsulated into a class. I hope it can help friends with the same title.
/*
* @ Access class
* Insert, update, delete record
* Version 1.0
* Date 2005.6
* Power by Samsun manzaro (34n pig)
*/
// ================================================ ====================
// Insert record
// Insert records
// ================================================ ====================
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'. $ table. '('. $ field. ') VALUES ('. $ ins .')';
// Echo $ SQL; exit;
$ Query = @ odbc_do ($ connid, $ SQL );
}
// ================================================ ======================================
// Get one record detail
// Obtain the specific 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