maloi59ru
Новичок
Дата регистрации:
20.03.2014 09:38:44
Сообщений: 8
вод код:
news_article_class.php
public function editNewsArticle($id, $title, $url_text) {
return $this->edit($id, array("title" => $title, "url_text" => $url_text));
}
abstract_global_class.php
protected function edit($id, $upd_fields) {
return $this->db->updateOnID($this->table_name, $id, $upd_fields);
}
database_class.php
public function updateOnID($table_name, $id, $upd_fields) {
return $this->update($table_name, array( "*" ) , "`id` = '$id'" ) ;
}
private function update($table_name, $upd_fields, $where) {
$table_name = $this->getTableName($table_name);
$query = "UPDATE $table_name SET ";
foreach ($upd_fields as $field => $value) $query .= "`$field` = '".addslashes($value)."',";
$query = substr($query, 0, -1);
if ($where) {
$query .= " WHERE $where";
return $this->query($query);
}
else return false;
}