PHP PDO Access Links
Copy Code code as follows:
Class Dbhelpclass
{
Private $conn;
Private $qxId;
Private $ret;
function __construct ()
{
$path = ". /.. /app_data/sd#f#45g_!. MDB ";
$constr = "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= ". Realpath ($path);
$this->conn= New PDO ("ODBC: $constr") or Die ("PDO Connection faild.");
}
/* Read * *
function Read ($sql, $params =array ())
{
$bind = $this->conn->prepare ($sql);
$arrKeys =array_keys ($params);
foreach ($arrKeys as $row)
{
$bind->bindvalue (":". $row, $params [$row]);
}
$bind->execute () or Die (' SQL error: '. $sql);
$result = $bind->fetchall ();
return $result;
}
/* Add, modify need to call this method * *
function Edit ($sql, $params =array ())
{
$bind = $this->conn->prepare ($sql);
$arrKeys =array_keys ($params);
foreach ($arrKeys as $row)
{
$bind->bindvalue (":". $row, $params [$row]);
}
$a = $bind->execute () or Die (' SQL error ');
return $a;
}
}
$DBH =new Dbhelpclass ();