Почему не получается построить запрос используя плейсхолдеры. Использую openserver для тестирования
if (isset($sql)) {
$sql = "INSERT INTO comments ( :columnts ) VALUES ( 1233 )";
$params = 'id';
$stm = self::$dbh->prepare($sql );
$stm->bindParam(':columnts', $params);
$stm->execute();
return true;
}
return false;
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? ) VALUES ( 1233 )' at line 1' in C:\OpenServer\domains\commentWall.loc\app\core\db\DbAdapter.php:89 Stack trace: #0 C:\OpenServer\domains\commentWall.loc\app\core\db\DbAdapter.php(89): PDO->prepare('INSERT INTO co...') #1 C:\OpenServer\domains\commentWall.loc\app\core\Model.php(41): app\core\db\DbAdapter->query('INSERT INTO co...', Array) #2 C:\OpenServer\domains\commentWall.loc\app\controllers\ControllerMain.php(36): app\core\Model->create(Array, Array) #3 C:\OpenServer\domains\commentWall.loc\app\Router.php(38): app\controllers\ControllerMain->actionIndex(NULL) #4 C:\OpenServer\domains\commentWall.loc\App.php(14): app\Router::execute(Array) #5 C:\OpenServer\domains\commentWall.loc\index.php(14): App::execute(Array) #6 {main} thrown