예제 #1
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;
 }
예제 #2
0
 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);
     }
     $object->setChildName($this->tblName);
     $this->structure->addJoinObject($this->tblName, $object);
     $this->objects[] = $object;
     if (empty($joinKey)) {
         $name = $object->getModel()->getTableName();
         $object->setJoinKey(create_join_key($this->model, $name));
     }
     return $this;
 }