예제 #1
0
 protected function createJoins($val, $inner = FALSE)
 {
     $driver = $this->connection->getSupplementalDriver();
     $reflection = $this->connection->getDatabaseReflection();
     $joins = array();
     preg_match_all('~\\b([a-z][\\w.:]*[.:])([a-z]\\w*)(\\s+IS\\b|\\s*<=>)?~i', $val, $matches);
     foreach ($matches[1] as $names) {
         $parent = $this->name;
         if ($names !== "{$parent}.") {
             // case-sensitive
             preg_match_all('~\\b([a-z][\\w]*)([.:])~', $names, $matches, PREG_SET_ORDER);
             foreach ($matches as $match) {
                 list(, $name, $delimiter) = $match;
                 if ($delimiter === ':') {
                     list($table, $primary) = $reflection->getHasManyReference($parent, $name);
                     $column = $reflection->getPrimary($parent);
                 } else {
                     list($table, $column) = $reflection->getBelongsToReference($parent, $name);
                     $primary = $reflection->getPrimary($table);
                 }
                 $joins[$name] = ' ' . (!isset($joins[$name]) && $inner && !isset($match[3]) ? 'INNER' : 'LEFT') . ' JOIN ' . $driver->delimite($table) . ($table !== $name ? ' AS ' . $driver->delimite($name) : '') . ' ON ' . $driver->delimite($parent) . '.' . $driver->delimite($column) . ' = ' . $driver->delimite($name) . '.' . $driver->delimite($primary);
                 $parent = $name;
             }
         }
     }
     return $joins;
 }
예제 #2
0
 /**
  * Creates filtered table representation.
  *
  * @param  string  database table name
  * @param  Nette\Database\Connection
  */
 public function __construct($table, Nette\Database\Connection $connection)
 {
     $this->name = $table;
     $this->connection = $connection;
     $this->primary = $connection->getDatabaseReflection()->getPrimary($table);
     $this->sqlBuilder = new SqlBuilder($this);
 }
예제 #3
0
 function __construct($table, Nette\Database\Connection $connection)
 {
     $this->name = $table;
     $this->connection = $connection;
     $this->primary = $connection->getDatabaseReflection()->getPrimary($table);
     $this->delimitedName = $this->tryDelimite($this->name);
     $this->delimitedPrimary = $connection->getSupplementalDriver()->delimite($this->primary);
 }
예제 #4
0
implements\Iterator,\ArrayAccess,\Countable{protected$connection;protected$name;protected$primary;protected$rows;protected$data;protected$select=array();protected$where=array();protected$conditions=array();protected$parameters=array();protected$order=array();protected$limit=NULL;protected$offset=NULL;protected$group='';protected$having='';protected$checkReferenceNewKeys=FALSE;protected$referenced=array();protected$referencing=array();protected$accessed;protected$prevAccessed;protected$keys=array();protected$delimitedName;protected$delimitedPrimary;function
__construct($table,Nette\Database\Connection$connection){$this->name=$table;$this->connection=$connection;$this->primary=$connection->getDatabaseReflection()->getPrimary($table);$this->delimitedName=$this->tryDelimite($this->name);$this->delimitedPrimary=$connection->getSupplementalDriver()->delimite($this->primary);}function