php - Select a column (having foreign key) without joining two tables -


i want select column (which has foreign key constraint) without creating joins on tables. have 2 tables named eventupdate , eventcategory. event column common in both tables. whenever try following code gives error.

please give suggestion. don't want create join.

$qb2 = $this->em->createquerybuilder();  $from = 'entities\eventcategory cat';  $qb2->add('from',$from)      ->select('cat.event')      ->where('cat.id=3);  $query=$qb2->getquery(); 

there 2 options can see:

  1. hint_include_meta_columns arrayhydrator

    $query = $querybuilder->getquery(); $query->sethint(\doctrine\orm\query::hint_include_meta_columns, true); var_dump($query->getarrayresult()); // return array raw foreign key column name => value, e.g. user_id => 5 
  2. create separate property in entities\eventcategory has foreign key primitive type

    /**  * @var user  *  * @manytoone(targetentity="user")  * @joincolumn(name="user_id", referencedcolumnname="user_id")  */ private $user;  /**  * @var int  *  * @column(name="user_id", type="integer", nullable=false)  */ private $userid; 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -