首页 \ 问答 \ PHP PDO数据不插入[重复](PHP PDO data does not inserting [duplicate])

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);
}

原文:
更新时间:2022-06-10 11:06

最满意答案

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.

相关问答

更多
  • Oracle中DDL和DML之间的一个主要(技术)区别是,DDL 不是事务性的,即它们不能回退并且不需要提交。 事实上,Oracle中的DDL在执行之前进行了隐式提交。 其他数据库(例如Postgres,DB2)对于DDL和DML之间的事务并没有什么不同 毕竟它只是一个分类,类似于“应用程序”和“服务器”(如在数据库服务器中)。 从操作角度来看,OpenOffice和Oracle都是简单的“应用程序”,但我们将它们分类到不同的类别中。 One major (technical) difference bet ...
  • 正如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 ...
  • 您可以使用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 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 ...
  • 如果要提供“系统”权限(“全局”权限) 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 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)