コード例 #1
0
ファイル: Finder.php プロジェクト: reoring/sabel
 public function __construct($mdlName, $projection = null)
 {
     $this->model = is_model($mdlName) ? $mdlName : MODEL($mdlName);
     if ($projection !== null) {
         $this->p($projection);
     }
 }
コード例 #2
0
ファイル: Model.php プロジェクト: reoring/sabel
 public function __construct($id = null)
 {
     if (is_model($id)) {
         $model = $id;
         $this->modelName = $model->getName();
     } else {
         if (is_empty($this->modelName)) {
             $exp = explode("_", get_class($this));
             $this->modelName = array_pop($exp);
         }
         $model = is_empty($id) ? MODEL($this->modelName) : MODEL($this->modelName, $id);
     }
     $this->setModel($model);
 }
コード例 #3
0
ファイル: Paginate.php プロジェクト: reoring/sabel
 public function __construct($model)
 {
     if (is_string($model)) {
         $model = MODEL($model);
     }
     if (is_model($model)) {
         $model->autoReinit(false);
         $this->method = "select";
     } elseif ($model instanceof Sabel_Db_Join) {
         $model->getModel()->autoReinit(false);
         $this->method = "join";
         $this->isJoin = true;
     } else {
         throw new Exception("Paginate::__construct() invalid instance.");
     }
     $this->model = $model;
 }
コード例 #4
0
ファイル: Paginator.php プロジェクト: hamaco/phwittr-on-xoops
 public function __construct($model, $pageKey = "page")
 {
     if (is_string($model)) {
         $model = MODEL($model);
     }
     if (is_model($model)) {
         $model->autoReinit(false);
     } elseif ($model instanceof Sabel_Db_Join) {
         $model->getModel()->autoReinit(false);
         $this->isJoin = true;
     } else {
         $message = __METHOD__ . "() invalid instance.";
         throw new Sabel_Exception_Runtime($message);
     }
     $this->model = $model;
     $this->attributes["pageKey"] = $pageKey;
 }
コード例 #5
0
ファイル: Relation.php プロジェクト: hamaco/phwittr-on-xoops
 public function add($object, $alias = "", $joinKey = array())
 {
     if (is_string($object)) {
         $object = new Sabel_Db_Join_Object(MODEL($object), $alias, $joinKey);
     } elseif (is_model($object)) {
         $object = new Sabel_Db_Join_Object($object, $alias, $joinKey);
     }
     $structure = Sabel_Db_Join_Structure::getInstance();
     $structure->addJoinObject($this->getName(), $object);
     $object->setChildName($this->getName());
     $this->objects[] = $object;
     if (empty($joinKey)) {
         $name = $object->getModel()->getTableName();
         $object->setJoinKey(create_join_key($this->model, $name));
     }
     return $this;
 }
コード例 #6
0
ファイル: Relation.php プロジェクト: reoring/sabel
 public function add($object, $on = array(), $alias = "", $type = "")
 {
     if (is_string($object) || is_model($object)) {
         $object = new Sabel_Db_Join_Object($object);
     }
     if (!empty($alias)) {
         $object->setAlias($alias);
     }
     if (!empty($type)) {
         $object->setJoinType($type);
     }
     $object->setChildName($this->getName());
     $structure = Sabel_Db_Join_Structure::getInstance();
     $structure->addJoinObject($this->getName(), $object);
     $this->objects[] = $object;
     if (!empty($on)) {
         $object->on($on);
     } elseif ($object->getOn() === array()) {
         $object->on(create_join_key($this->model, $object->getModel()->getTableName()));
     }
     return $this;
 }
コード例 #7
0
ファイル: Model.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @param mixed $arg1
  * @param mixed $arg2
  *
  * @return void
  */
 public function setCondition($arg1, $arg2 = null)
 {
     if (!empty($arg1)) {
         $condition = $this->getCondition();
         if ($arg2 !== null) {
             $condition->create($arg1, $arg2);
         } elseif (is_model($arg1)) {
             $joinkey = create_join_key($this, $arg1->getTableName());
             $colName = $this->getTableName() . "." . $joinkey["fkey"];
             $condition->create($colName, $arg1->{$joinkey}["id"]);
         } elseif (is_object($arg1)) {
             $condition->add($arg1);
         } else {
             $colName = $this->getTableName() . "." . $this->metadata->getPrimaryKey();
             $condition->create($colName, $arg1);
         }
     }
     return $this;
 }