タグ

ブックマーク / www.1x1.jp (2)

  • CakePHP Modelに関する6つの誤解

    CakePHPのModelはActiveRecordライクなDBアクセス方法を提供しており、さらにアソシエーションを設定することにより複数テーブルの値を同時に操作できるなど、DB操作に対するインターフェイスが数多くあります。 ただ「手軽にDB操作ができる」という印象が先行しているゆえ誤解を招くことがあるようです。 1. クラス名に対応したテーブルしか操作できない Modelのクラス名とテーブルを自動でマッピングするのはフレームワークのいわば便利機能です。デフォルトでそのような動作をするだけで、容易に変更することができます。 Model#$useTableにテーブル名を指定すれば任意のテーブルを操作できます。 <?php class Foo extends AppModel { public $useTable = 't_user'; // t_userテーブル } ?> 2. DBを使わな

    polidog
    polidog 2009/12/10
    同感
  • CakePHP cache()はCache::write()に

    CakePHPにはキャッシュを行う関数cache()があるのですが、1.2.2のソースを見るとdeprectatedになってました。 [cake/basics.php] <?php /** * Reads/writes temporary data to cache files or session. * * @param string $path File path within /tmp to save the file. * @param mixed $data The data to save to the temporary file. * @param mixed $expires A valid strtotime string when the data expires. * @param string $target The target of the cached da

  • 1