2013-07-29 118 views
1

我正在開發一個站點,它將從各大知名汽車經銷商(即Fordham豐田,Westchester豐田,豐田曼哈頓等),從CitySeach,經銷商Rater ,內部人員頁面,Yelp,雅虎本地,Google+等。基本上這個網站的功能是讓企業主可以在主要的評論網站上監控他們的在線評論。無法使用codeigniter數據映射器從mysql數據庫中刪除記錄

我在這個項目中使用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條評論。

每當我要刪除一個配置文件,該配置文件的審查應被刪除,但在這裏我得到這樣的錯誤消息:

「致命的錯誤:讓內存耗盡134217728個字節大小(試圖分配20字節)在/ home/business/public_html/system/database/DB_active_rec.php在線1999

任何人都可以請建議我這方面。

+0

顯示我們查詢,也許我們可以優化它! –

+0

這裏是我的代碼如下: $ profile = new Profile($ id);如果($ key ==='user') 繼續;如果($ profile-> result_count()> 0){foreach($ profile-> has_many as $ key => $ value){ $ profile - > {$ key} - > delete_all(); $ profile-> delete($ profile - > {$ key} - > all); } $ profile-> delete(); } – user2198137

+0

可能的重複[無法使用codeigniter datamapper從mysql數據庫中刪除超過20000條記錄](http://stackoverflow.com/questions/17940067/unable-to-delete-more-than-20000-records-from- mysql-database-using-codeigniter-d) – Wietse

回答

0

嘗試改變內存限制是這樣的:

ini_set('memory_limit', '-1'); 
+0

可能不是正確的路線,編寫代碼以達到極限幾乎總是更好。 –

+0

@JohnV。我同意你的看法,但我試圖獲得更多的數據,但我沒有。所以,我有這個問題,我無法回答。 –