예제 #1
0
 public function addAll(Gpf_DbEngine_Table $table, $tableAlias = '')
 {
     $alias = '';
     if ($tableAlias != '') {
         $alias = $tableAlias . '.';
     }
     foreach ($table->getColumns() as $column) {
         $this->add($alias . $column->getName());
     }
 }
예제 #2
0
 public function fromSelect(Gpf_SqlBuilder_SelectBuilder $selectBuilder)
 {
     $this->fromSelect = $selectBuilder->toString();
     foreach ($selectBuilder->select->getColumns() as $column) {
         if ($this->table !== null && !$this->table->hasColumn($column->getAlias())) {
             throw new Gpf_Exception('Column ' . $column->getAlias() . " doesn't exist in {$this->tableName}.");
         }
         $i = count($this->columns);
         $this->columns[$i]['column'] = $column->getAlias();
     }
 }
예제 #3
0
 private function updateRow($updateColumns = array())
 {
     $updateBuilder = $this->createUpdateBuilder();
     $updateBuilder->from->add($this->table->name());
     foreach ($this->tableColumns as $column) {
         if (count($updateColumns) > 0 && !in_array($column->name, $updateColumns, true)) {
             continue;
         }
         $columnValue = $this->getInternalValue($column->name);
         if (!$this->table->isPrimary($column->name) && $columnValue !== null) {
             if ($columnValue == self::NULL) {
                 $updateBuilder->set->add($column->name, 'NULL', false);
             } else {
                 $updateBuilder->set->add($column->name, $columnValue, $column->doQuote());
             }
         }
     }
     $updateBuilder->where = $this->getPrimaryWhereClause();
     $updateBuilder->updateOne();
 }
예제 #4
0
 public function name() {
     return parent::name() . $this->index;
 }
예제 #5
0
    /**
     * HACK: mosso MySQL servers can not handle large result sets so the select has to be splitted
     */
    protected function doMossoHack(Gpf_DbEngine_Table $primaryTable, $primaryTableAlias, $primaryColumnName) {
        $orderSelect = new Gpf_SqlBuilder_SelectBuilder();
        $orderSelect->cloneObj($this->_selectBuilder);
        $orderSelect->select = new Gpf_SqlBuilder_SelectClause();
        $orderSelect->select->add($primaryTableAlias.'.'.$primaryColumnName, 'idCol');
        foreach ($orderSelect->orderBy->getAllOrderColumns() as $orderColumns) {
            $dataColumn = $this->dataColumns[$orderColumns->getName()];
            $orderSelect->select->add($dataColumn->getName(), $dataColumn->getId());
        }

        $this->_selectBuilder->from = new Gpf_SqlBuilder_FromClause();
        $this->_selectBuilder->from->addSubselect($orderSelect, 'ors');
        $this->_selectBuilder->from->addInnerJoin($primaryTable->name(), $primaryTableAlias,
        $primaryTableAlias.'.'.$primaryColumnName.'=ors.idCol');
        $i = 0;
        foreach ($orderSelect->from->getAllFroms() as $fromClause) {
            if ($i++ == 0) {
                continue;
            }
            $this->_selectBuilder->from->addClause($fromClause);
        }
        $this->_selectBuilder->limit = new Gpf_SqlBuilder_LimitClause();
    }
예제 #6
0
 public function addAll(Gpf_DbEngine_Table $table, $tableAlias = '')
 {
     foreach ($table->getColumns() as $column) {
         $this->add($column->getName(), $column->getName(), $tableAlias);
     }
 }