CakePHP 中有超过 3000 笔交易。如何?
我们正在通过 SOAP 将 Magento 产品导入 CakePHP 环境。我们有大约 3000 种产品,当然我们希望保持数据库中没有重复条目。
我们在 CakePHP 中使用 InnoDB 作为产品数据库。
我们有不同的方法:
- 我们在产品模型上设置验证变量,并希望产品 ID 是唯一的。问题:交易限制为 2.000 回合。由于验证的唯一规则需要每个产品的 SELECT 语句,因此不会发生任何事情,因为事务已被“消耗”。
- 将产品 ID 设置为数据库本身中唯一的。看起来不错,唯一的问题是,第一次导入后它总是抛出“重复条目”警告(这是正确的)并且不会继续。 我找不到如何在该查询上使用“忽略”的方法。
有什么想法吗?
We are doing an import of Magento-products into a CakePHP environment over SOAP. We have like 3.000 products and of course we want to keep the database clean of duplicate entrys.
We use InnoDB as product-databse in CakePHP.
We had different approaches:
- We set the validate var on the product model and want the product-id to be unique. Problem: The transactions are limited to roundabout 2.000. Since the unique-rule for validation requires SELECT-statements for each product, nothing happens because the transactions are "consumed".
- Set product-id unique in the database itself. Seems good, only problem is, after the first import it always throws a "duplicate entry"-warning (which is correct) and doesn't go on.
I found no way how to use "ignore" on that query.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于问题与 SQL 相关并且是导入,因此我将手动构建查询。也许写入 tmp/ 目录中的文件。所有这些插入可以构成 1 个事务。这样您就可以将重复键忽略添加到查询中。
就其本质而言,CakePHP 运行大量查询,并且由于交易受到限制,所以我不会选择 cake。
当然,您可以更深入地研究 cake 并弄清楚它的 innodb 类是如何工作的,并看看是否有办法将查询包装到事务中。
Since the problem is SQL related and it is an import, I would build the queries manually. Perhaps write out to a file in the tmp/ directory. All of these inserts can make up 1 transaction. This way you can add the on duplicate key ignore to the queries.
By its very nature, CakePHP runs numerous queries and since you are limited on transactions, I wouldn't go with cake.
Of course you can dig into cake a little bit deeper and figure out how its innodb class works and see if there is a way to wrap queries into a transaction.