コード例 #1
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;
 }
コード例 #2
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;
 }
コード例 #3
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;
 }