Пример #1
0
 public function getProjection(Sabel_Db_Statement $stmt)
 {
     $projection = array();
     $name = $this->hasAlias() ? strtolower($this->aliasName) : $this->tblName;
     foreach ($this->columns as $column) {
         $as = "{$name}.{$column}";
         if (strlen($as) > 30) {
             $as = Sabel_Db_Join_ColumnHash::toHash($as);
         }
         $p = $stmt->quoteIdentifier($name) . "." . $stmt->quoteIdentifier($column);
         $projection[] = $p . " AS " . $stmt->quoteIdentifier($as);
     }
     return $projection;
 }
Пример #2
0
 public function createModel(&$row)
 {
     $name = $this->tblName;
     static $models = array();
     if (isset($models[$name])) {
         $model = clone $models[$name];
     } else {
         $model = MODEL(convert_to_modelname($name));
         $models[$name] = clone $model;
     }
     if ($this->hasAlias()) {
         $name = strtolower($this->aliasName);
     }
     $props = array();
     foreach ($this->columns as $column) {
         $hash = Sabel_Db_Join_ColumnHash::getHash("{$name}.{$column}");
         if (isset($row[$hash])) {
             $props[$column] = $row[$hash];
             unset($row[$hash]);
         }
     }
     $model->setProperties($props);
     return $model;
 }
Пример #3
0
 protected function createProjection(Sabel_Db_Statement $stmt)
 {
     if (empty($this->projection)) {
         $projection = array();
         foreach ($this->objects as $object) {
             $projection = array_merge($projection, $object->getProjection($stmt));
         }
         $quotedTblName = $stmt->quoteIdentifier($this->tblName);
         foreach ($this->model->getColumnNames() as $column) {
             $projection[] = $quotedTblName . "." . $stmt->quoteIdentifier($column);
         }
     } else {
         $projection = array();
         foreach ($this->projection as $name => $proj) {
             if (($tblName = convert_to_tablename($name)) === $this->tblName) {
                 foreach ($proj as $column) {
                     $projection[] = $stmt->quoteIdentifier($tblName) . "." . $stmt->quoteIdentifier($column);
                 }
             } else {
                 foreach ($proj as $column) {
                     $as = "{$tblName}.{$column}";
                     if (strlen($as) > 30) {
                         $as = Sabel_Db_Join_ColumnHash::toHash($as);
                     }
                     $p = $stmt->quoteIdentifier($tblName) . "." . $stmt->quoteIdentifier($column);
                     $projection[] = $p . " AS " . $stmt->quoteIdentifier($as);
                 }
             }
         }
     }
     return implode(", ", $projection);
 }
Пример #4
0
 public static function clear()
 {
     self::$columns = array();
 }