/var/www/doncode.com.ua/www/libs
Edit: /var/www/doncode.com.ua/www/libs/class.database.php (2065B)
query("set names $ENCODE");
$this->query("SET lc_time_names = 'ru_RU'");
$this -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION );
$this -> setAttribute ( PDO :: ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC );
}catch (Exception $e){
echo $e->getMessage();
}
}
public function insert($table, $data)
{
ksort($data);
$fieldsNames = implode('`,`', array_keys($data));
$fieldsValues = ':' . implode(',:', array_keys($data));
$sth = $this->prepare("INSERT INTO `$table` (`$fieldsNames`)VALUES ($fieldsValues);");
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$sth->execute();
return $this->lastInsertId();
}
public function log ($msg,$parent_class=''){
$this->insert('logs',array(
'action' =>$msg,
'users_login' =>session::get('login'),
'ip' =>$_SERVER["REMOTE_ADDR"],
'func' =>$parent_class
));
}
public function update($table, $data, $where)
{
$fieldDetails = '';
foreach ($data as $key => $value) {
$fieldDetails .= "`$key`=:$key,";
}
$fieldDetails = rtrim($fieldDetails, ',');
$sth = $this->prepare("UPDATE `$table` SET $fieldDetails WHERE $where ;");
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$sth->execute();
return $sth->rowCount();
}
}
?>