Cake\ORM\Query::addDefaultTypes PHP Method

addDefaultTypes() public method

This method returns the same query object for chaining.
public addDefaultTypes ( Table $table )
$table Table The table to pull types from
    public function addDefaultTypes(Table $table)
    {
        $alias = $table->alias();
        $map = $table->schema()->typeMap();
        $fields = [];
        foreach ($map as $f => $type) {
            $fields[$f] = $fields[$alias . '.' . $f] = $fields[$alias . '__' . $f] = $type;
        }
        $this->typeMap()->addDefaults($fields);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Append a join to the junction table.
  *
  * @param \Cake\ORM\Query $query The query to append.
  * @param string|array $conditions The query conditions to use.
  * @return \Cake\ORM\Query The modified query.
  */
 protected function _appendJunctionJoin($query, $conditions)
 {
     $name = $this->_junctionAssociationName();
     $joins = $query->join();
     $matching = [$name => ['table' => $this->junction()->table(), 'conditions' => $conditions, 'type' => 'INNER']];
     $assoc = $this->target()->association($name);
     $query->addDefaultTypes($assoc->target())->join($matching + $joins, [], true);
     $query->eagerLoader()->addToJoinsMap($name, $assoc);
     return $query;
 }
All Usage Examples Of Cake\ORM\Query::addDefaultTypes