LoginSignup
3
3

More than 5 years have passed since last update.

【ZF2】モデルでのスキーマ指定

Last updated at Posted at 2014-09-26

【ZF2】モデルでのスキーマ指定

zf2でスキーマを指定する場合は、  
TableGateWayを初期化する際第一引数にテーブル名の文字列を渡す代わりに、
下記のようにスキーマを指定したTableIdentifierのオブジェクトを渡す。

public function setDbAdapter(Adapter $adapter, $schema = 'default')
{
 $table = new \Zend\Db\Sql\TableIdentifier($this->tableName, $schema);
 $tableClassName = 'Application\Model\Table\\' . $this->tableClassName;
 $resultSetPrototype = new ResultSet();
 $resultSetPrototype->setArrayObjectPrototype(new $tableClassName());
 $this->gateway = new TableGateway($table, $adapter, null, $resultSetPrototype);
 }

ZF2変わり過ぎ!

クラスオートロードやイベント管理、Actionヘルパーの廃止など、
かなり別ゲーになっているので、続編だと思って油断していると  
マイグレーションの際に(´・ω・`)ってなる   

http://stackoverflow.com/questions/16133393/zend-framework-2-action-helper

This only reduces your work of migration you will be loosing lots of advantages of ZF2 and also you can't really exploit the features of a framework .

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3