Vadim666
Новичок
Нету никаких ошибок и не добавляет запись
Модель
public static function createArticle($options){
// Соединение с БД
$db = Db::getConnection();
// Текст запроса к БД
$sql = 'INSERT INTO article (title, short_content, content, author_name) '
. 'VALUES
title, :short_content, :content, :author_name)';
// Получение и возврат результатов. Используется подготовленный запрос
$result = $db->prepare($sql);
$result->bindParam(':title', $options['title'], PDO:
ARAM_STR);
$result->bindParam(':short_content', $options['short_content'], PDO:
ARAM_STR);
$result->bindParam(':content', $options['content'], PDO:
ARAM_STR);
$result->bindParam(':author_name', $options['author_name'], PDO:
ARAM_INT);
return $result->execute($options);
}
Получаю данные
public function actionCreate(){
// Обработка формы
if (isset($_POST['submit'])){
// Если форма отправлена
// Получпем данные из формы
$options['title'] = $_POST['title'];
$options['short_content'] = $_POST['short_content'];
$options['content'] = $_POST['content'];
$options['author_name'] = $_POST['author_name'];
// Если запись добавлена
if(Add::createArticle($options)) {
header("Location: /");
}
}
require_once(ROOT . '/views/add/index.php');
return true;
}
Модель
public static function createArticle($options){
// Соединение с БД
$db = Db::getConnection();
// Текст запроса к БД
$sql = 'INSERT INTO article (title, short_content, content, author_name) '
. 'VALUES

// Получение и возврат результатов. Используется подготовленный запрос
$result = $db->prepare($sql);
$result->bindParam(':title', $options['title'], PDO:

$result->bindParam(':short_content', $options['short_content'], PDO:

$result->bindParam(':content', $options['content'], PDO:

$result->bindParam(':author_name', $options['author_name'], PDO:

return $result->execute($options);
}
Получаю данные
public function actionCreate(){
// Обработка формы
if (isset($_POST['submit'])){
// Если форма отправлена
// Получпем данные из формы
$options['title'] = $_POST['title'];
$options['short_content'] = $_POST['short_content'];
$options['content'] = $_POST['content'];
$options['author_name'] = $_POST['author_name'];
// Если запись добавлена
if(Add::createArticle($options)) {
header("Location: /");
}
}
require_once(ROOT . '/views/add/index.php');
return true;
}