public function edit($tablename, $datafields = array(), $tablefields = array(), $condition) { //edit data $dbconfig = new DBconfig(); $host = $dbconfig->host(); $user = $dbconfig->username(); $pwd = $dbconfig->pwd(); $db = $dbconfig->db(); $set = DBmain::mixingforupdatequery($datafields, $tablefields); try { $conn = new PDO("mysql:host={$host};dbname={$db}", $user, $pwd); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "UPDATE " . $tablename . " SET " . $set . " WHERE " . $condition . ""; // use exec() because no results are returned $conn->exec($sql); } catch (PDOException $e) { echo $sql . "<br>" . $e->getMessage(); } $conn = null; }
public function edit($tablename, $datafields = array(), $tablefields = array(), $condition) { //edit data $set = DBmain::mixingforupdatequery($datafields, $tablefields); try { $sql = "UPDATE " . $tablename . " SET " . $set . " " . $condition . ""; // use exec() because no results are returned $this->conn->exec($sql); } catch (PDOException $e) { echo $sql . "<br>" . $e->getMessage(); } $conn = null; }