コード例 #1
0
ファイル: Joined.php プロジェクト: TheProjecter/sylma
 /**
  * @usedby sql\template\view\Foreign::reflectFunctionJoin()
  * @usedby sql\template\view\Foreign::buildSingle()
  * @usedby sql\template\view\Foreign::buildMultiple()
  * @usedby sql\template\view\Reference::reflectFunctionJoin()
  */
 public function addJoin(sql\schema\table $result, sql\schema\element $field, $val, $bClone = false)
 {
     $bAdd = true;
     foreach ($this->aJoinsElements as $aJoin) {
         if ($aJoin[0] === $val && $aJoin[1] === $result->getName()) {
             $bAdd = false;
         }
     }
     if ($bAdd) {
         if (!$bClone) {
             $sName = $result->getName();
             if (isset($this->aJoinsTables[$sName])) {
                 $result = clone $result;
                 $field = $result->getElement($field->getName());
                 //$field = clone $field; // @todo : not great, cloned but not referenced in table
                 $result->setAlias($sName . $this->aJoinsTables[$sName]);
                 $field->setParent($result);
                 $this->aJoinsTables[$sName]++;
             } else {
                 $this->aJoinsTables[$sName] = 1;
             }
         }
         foreach ($this->getClones() as $clone) {
             $clone->addJoin($result, $field, $val, true);
         }
         $this->aJoins[] = array($result->asAlias(), $field, $val);
         $this->aJoinsElements[] = array($val, $result->getName());
     }
     return $result;
 }
コード例 #2
0
ファイル: Foreign.php プロジェクト: TheProjecter/sylma
 /**
  * @uses Table::getDummy()
  * @return array
  */
 public function buildMultiple(sql\schema\table $junction, sql\schema\foreign $source, sql\schema\foreign $target)
 {
     if ($this->getParent()->isSub()) {
         $dummy = $this->getParent()->getDummy();
         $collection = $dummy->call('getElement', array($this->getName()))->call('getValue');
     } else {
         $collection = $this->getParent()->getElementArgument($this->getName(), 'get');
     }
     $window = $this->getWindow();
     $val = $window->createVariable('', 'php-null');
     $key = $window->createVariable('', 'php-integer');
     $loop = $window->createLoop($collection, $val, $key);
     $junction->init($key, $this->getParent()->getDummy(false));
     $junction->addElement($source, $this->reflectKey());
     $junction->addElement($target, $val);
     $loop->addContent($junction);
     $result = $loop;
     return $result;
 }