Take the risk of thinking for yourself; much more happiness, truth, beauty and wisdom will come to you that way.- Christopher Hitchens

Archive for the 'Cakephp' Tag

— [cakephp]定数の定義をするのに最適なとこ

Posted: Nov 9, 2007, 9:24 pm | Author: cyberryo | Category: Dialy | Tags:

define(‘URL’,'http://www.hoge.com/’);

こんな感じでURLなど定数で定義してあると、開発環境が違うときに大変便利ですよー。
ということで、cakephpはどこで定数を定義すればよいのか。

アプリ全体→app/config/bootstrap.php
コントローラ→app/app_controller.php
モデル→app/app_model.php


— [cakephp]findAllByでorderしたい

Posted: Nov 6, 2007, 4:42 pm | Author: cyberryo | Category: Dialy | Tags:

基本的には下記findAllと同じらしい。

Model::findAll($conditions = null,
        $fields = null,
        $order = null,
        $limit = null,
        $page = 1,
        $recursive = null
)

つまり、

$model = $this->Model->findAllById($id,null,’created DESC’);

これも知ってるか知らないかで差が出ますねー。


— [cakephp]findByで複数条件の指定

Posted: Oct 20, 2007, 10:57 am | Author: cyberryo | Category: Dialy | Tags: , ,

あらー、もっと早く気づけば良かった。
大変便利だ。

$this->Model->findByIdAndName( $id, $name )

追記(07/11/13)
PHP4の場合は

$this->Model->findById_And_Name( $id, $name )

アンダーバーが入ります。

ローカルはPHP5、運用はPHP4、そんなアンバランスな開発やってると勉強になりますね(笑)


— [cakephp]cakephpの命名規則に従わなかったツケがやってきた

Posted: Oct 17, 2007, 3:02 pm | Author: cyberryo | Category: Dialy | Tags: , ,

最近はもっぱらフレームワークで開発する機会が多くなりました。
現在Cakephpでポータルサイトを開発しているのですが、、、
Read the rest of this entry »