cakephp2.X です。
ビューテーブルを、Cakephp内でモデルとして扱おうとしてます。
ビューテーブルの取得結果自体は大した量ではない(300行程度)ですが、
モデルのfind(all)でタイムアウトしてしまいます。
※SQLのSELECT結果は、0.000 sec.でした
error
1Error: Maximum execution time of 30 seconds exceeded
findで「all」をしているというのもあるかと思いますが、タイムアウトするほど??と思います。
CakePHPからビューテーブルを利用すると、内部でリソースを消費するのでしょうか?
ビューテーブルの扱いが初めてで、よく分かりません。
宜しくお願い致します。
・ビューテーブル
SQL
1CREATE VIEW comment_views AS 2select user_id count(id) as c_count from users 3group by user_id , blog_id
・コントローラ
php
1 2 3public function index() { 4 5 $this->loadModel('CommentView'); 6 val = $this->CommentView->findByUserId($id); //ここでエラー 7} 8
・モデル
php
1 2<?php 3 4App::uses('AppModel', 'Model'); 5 6class CommentView extends AppModel { 7 8 9 public function findByUserId($user_id) 10 { 11 //ここでタイムアウト 12 return $this->find('all',array('order' => array('comment_id DESC'),'conditions' => array('CommentView.user_id' => $user_id,))); 13 } 14 15 16 17} 18 19
あなたの回答
tips
プレビュー