Skip to content

Instantly share code, notes, and snippets.

@magefad
Last active December 14, 2015 08:09
Show Gist options
  • Save magefad/5055908 to your computer and use it in GitHub Desktop.
Save magefad/5055908 to your computer and use it in GitHub Desktop.
Yii мульти-табличный CActiveRecord / multitable CActiveRecord
<?php
class ActiveRecord extends CActiveRecord
{
private static $_tableName;
public static function instance($tableName)
{
self::$_tableName=$tableName;
return parent::model(__CLASS__);
}
public function tableName()
{
return self::$_tableName;
}
}
@magefad
Copy link
Author

magefad commented Feb 28, 2013

Using

$models = MyModelName::instance('my_table_name')->findAll();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment