【发布时间】:2023-04-06 16:48:02
【问题描述】:
我正在开发一个网站,该网站将从 CitySeach、Dealer Rater、Insider Pages、Yelp、Yahoo-local、 Google+ 等。基本上这个网站的功能是允许企业主监控他们在主要评论网站上的在线评论。
我在这个项目中使用了codeigniter和datamapper(1.8版),在从mysql数据库中删除数据时遇到了一些问题。
这是我的部分表结构如下:
+----------+ +----------------+ +--------------+
| Profile | | profiles_users | | users |
+----------+ +----------------+ +--------------+
| id |<---- | id |----->| id |
| name | | profile_id | | name |
+----------+ | user_id | | email |
| +----------------+ | password |
| +--------------+
+--> +--------------+
| reviews |
+--------------+
| id |
| title |
| author |
| review |
| rating |
| date |
| profile_id |
+--------------+
在“个人资料”表中,我存储了 delar 名称(即福特汉姆丰田、威彻斯特丰田等),在“用户”表中,我存储了企业主的姓名。我正在使用 api 来获取评论并将它们存储在带有“profile-id”的“评论”表中。
每个个人资料可能有超过 20000 条评论。目前我有平均。每个配置文件有 12000 条评论。
每当我要删除个人资料时,都应该删除该个人资料的评论,但在这里我会收到一条错误消息,例如 :
“致命错误:1999 行 /home/business/public_html/system/database/DB_active_rec.php 中允许的内存大小为 134217728 字节已用尽(尝试分配 20 字节)”
谁能在这方面给我建议。
【问题讨论】:
-
向我们展示查询,也许我们可以优化它!
-
我的代码如下: $profile = new Profile($id); if ($profile->result_count() > 0) { foreach($profile->has_many as $key => $value){ if ($key === 'user') 继续; $profile->{$key}->delete_all(); $profile->delete($profile->{$key}->all); } $profile->delete(); }
标签: php codeigniter codeigniter-datamapper