Monday, April 18, 2011

PHP notes (ADODB)

Catatan penggunaan ADODB :
include('adodb/adodb.inc.php');

//--> Koneksi ke database
$_PATH  = "C:\\FILE\DATA.mdb";
$db     =& ADONewConnection('access');
$dsn    = "Driver={Microsoft Access Driver (*.mdb)};Dbq={$_PATH};Uid=Admin;Pwd=;";
$db->Connect($dsn);
$db->SetFetchMode(ADODB_FETCH_ASSOC);

//--> Eksekusi query
$sql = "SELECT * FROM Q_COI WHERE CMP.ID = {$_ID}";
$rs  = $db->Execute($sql);
$jml = $rs->RecordCount()."";

while (!$rs->EOF) {
  $data[$rs->fields['group']]['data'][] = $rs->fields;
  $rs->MoveNext();
}