PHP PDO数据不插入[重复](PHP PDO data does not inserting [duplicate])
这个问题在这里已有答案:
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 'keys) VALUES ('1','159')' at line 1' in C:\xampp\htdocs\***\index12.php:93 Stack trace: #0 C:\xampp\htdocs\***\index12.php(93): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\***\index12.php on line 93 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); for($i = 1; $i < sizeof($counts_index);$i++){ //echo $i.": ".$counts_index[$i]."<br/>"; $index = $counts_index[$i]; $sql1 = "INSERT INTO asce (idn,keys) VALUES (:idn,:keys)"; $q1 = $dbh->prepare($sql1); $params1 = array( ':idn'=>$i, ':keys'=> $index ); $q1->execute($params1); }
This question already has an answer here:
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 'keys) VALUES ('1','159')' at line 1' in C:\xampp\htdocs\***\index12.php:93 Stack trace: #0 C:\xampp\htdocs\***\index12.php(93): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\***\index12.php on line 93 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); for($i = 1; $i < sizeof($counts_index);$i++){ //echo $i.": ".$counts_index[$i]."<br/>"; $index = $counts_index[$i]; $sql1 = "INSERT INTO asce (idn,keys) VALUES (:idn,:keys)"; $q1 = $dbh->prepare($sql1); $params1 = array( ':idn'=>$i, ':keys'=> $index ); $q1->execute($params1); }
原文:
最满意答案
PostgreSQL的
我会说这是PostgreSQL中的DML语句:PostgreSQL具有TRUNCATE触发器,但PostgreSQL没有DDL触发器。 所以它不能成为DDL语句。
它在它操作的每个表上获得一个ACCESS EXCLUSIVE锁,它不是MVCC安全的,但它是事务安全的,可以进行回滚。
为TRUNCATE触发触发器的能力是SQL标准的PostgreSQL扩展。
PostgreSQL
I would say it's a DML statement in PostgreSQL: PostgreSQL has a TRUNCATE trigger but PostgreSQL doesn't have DDL triggers. So it can't be a DDL statement.
It acquires an ACCESS EXCLUSIVE lock on each table it operates on and it's not MVCC-safe but it's transactionsafe and you can do a rollback.
The ability to fire triggers for TRUNCATE is a PostgreSQL extension of the SQL standard.
相关问答
更多-
数据库实现DDL和DML的方式有什么不同?(Is there a difference in the way DDLs and DMLs are implemented by a database?)[2022-04-24]
Oracle中DDL和DML之间的一个主要(技术)区别是,DDL 不是事务性的,即它们不能回退并且不需要提交。 事实上,Oracle中的DDL在执行之前进行了隐式提交。 其他数据库(例如Postgres,DB2)对于DDL和DML之间的事务并没有什么不同 毕竟它只是一个分类,类似于“应用程序”和“服务器”(如在数据库服务器中)。 从操作角度来看,OpenOffice和Oracle都是简单的“应用程序”,但我们将它们分类到不同的类别中。 One major (technical) difference bet ... -
来自DML触发器的SQL语句(SQL Statement from DML Trigger)[2022-07-14]
正如Jonas所说,Profiler是您的最佳选择(也是SELECT查询的唯一选项)。 对于INSERT,UPDATE,DELETE,没有Profiler的情况下最接近的可能是通过DBCC INPUTBUFFER(@@SPID)查看输入缓冲区。 这只适用于临时语言事件,而不是RPC调用,并且只会显示SQL语句的前256个字符(取决于版本,我相信)。 一些示例代码,(以dbo身份运行): CREATE TABLE TBL (a int, b varchar(50)) go INSERT INTO TBL S ... -
您应该可以使用PutSQL处理器来执行DML / DDL语句。 ExecuteSQL用于返回结果集的语句/查询,PutSQL用于不返回结果集的语句(INSERT,DML,DDL)。 You should be able to do DML/DDL statements using the PutSQL processor. ExecuteSQL is for statements/queries that return result set(s), PutSQL is for statements (INS ...
-
我想你可以用 DBCC CHECKIDENT ('TableName', RESEED, 0) 对于使用IDENTITY列的所有表。 I think you can use DBCC CHECKIDENT ('TableName', RESEED, 0) for all tables which use IDENTITY column.
-
使用schema.rb无法实现您想要的功能,您要做的是切换到使用数据库的本机模式转储/检索代码。 config.active_record.schema_format = :sql 现在,您将获得一个structure.sql文件,而不是schema.rb文件。 这应该透明地适用于所有rails的内置任务,并且因为它使用本机转储器格式,它将支持你想要的任何疯狂的东西。 There's no way to achieve what you want with schema.rb, what you want ...
-
DML统计,oracle(DML statistics, oracle)[2022-09-08]
您可以使用monitoring功能和dba_tab_modifications表来获取该信息。 例如,请参见此处或此处 。 You can use the monitoring feature and the dba_tab_modifications table to get that information. See for example here or here. -
ALTER技术上讲, ALTER将是DDL(数据定义语言),因为它会更改基础表/结构。 DML(数据操作语言)将类似于: UPDATE comics SET originalPriceDollars=6.99 WHERE title='Star Wars: Darth Maul' AND issueNumber=1; 基本上UPDATE和INSERT更改数据, ALTER更改基础表/结构。 ALTER would technically be DDL (Data Definition Langu ...
-
WITH sql中的dml查询(dml query within WITH sql)[2023-11-12]
试试这种方式: with temp as ( SELECT row_number() OVER (ORDER BY [ShareItems].ItemId) AS Row, ItemId FROM [ShareItems] ) select @row = ItemId from temp Try this way: with temp as ( SELECT row_number() OVER (ORDER BY [ShareItems].ItemId) AS Row, I ... -
授予DML和DBA权限(Granting DML and DBA Privileges)[2022-09-09]
如果要提供“系统”权限(“全局”权限) grant dba to shelby; 如果你想给“对象”特权(在特定的对象,表,视图等..) grant select on employees to shelby; grant insert on employees to shelby; grant update, alter on employees to shelby; If you want to give "system" privileges ("global" privileges) grant ... -
TRUNCATE是DML语句吗?(Is TRUNCATE a DML statement?)[2022-07-24]
PostgreSQL的 我会说这是PostgreSQL中的DML语句:PostgreSQL具有TRUNCATE触发器,但PostgreSQL没有DDL触发器。 所以它不能成为DDL语句。 它在它操作的每个表上获得一个ACCESS EXCLUSIVE锁,它不是MVCC安全的,但它是事务安全的,可以进行回滚。 为TRUNCATE触发触发器的能力是SQL标准的PostgreSQL扩展。 PostgreSQL I would say it's a DML statement in PostgreSQL: Postg ...