Exemplo n.º 1
0
 /**
  *	Method to update the record
  *
  *	@since 1.0.0
  *	@access public
  *
  *	@return int Number of updated rows
  **/
 public function update($data)
 {
     // Initialize PDO object
     $this->queryInit();
     // Extract the columns
     $columns = array_keys($data);
     $columns = implode('=?, ', $columns) . '=?';
     // Extract the values
     $values = array_values($data);
     // Build update query
     $query = sprintf("UPDATE %s SET %s %s", $this->table, $columns, $this->where ? 'WHERE ' . $this->where : '');
     // Reset SQL query
     $this->resetQuery();
     // Prepare and execute update query
     $update = $this->pdo->prepare($query);
     $update->execute($values);
     return $update->rowCount();
 }
Exemplo n.º 2
0
 /**
  * Добавляет статью в базу данных
  *
  * @param reference $conn Соединение с БД
  * @param int $authId Идентификатор автора статьи
  * @param int $catId Идентификатор категории
  * @param datetime $pubDate Дата публикации статьи
  */
 public function EditArticle($conn, $params, $authId = NULL, $catId = NULL, $pubDate = NULL)
 {
     $allowed = array("name", "content", "pubdate");
     $sql = "INSERT INTO Articles SET " . Model::pdoSet($allowed, $values);
     $stm = $conn->prepare($sql);
     $stm->execute($values);
     Article::UpdateLinks($conn, $params);
 }