laravel - Doctrine leftJoin with queryBuilder -
i'm trying use querybuilder doctrine data database query joining 2 tables. i'm getting error. tables have entities: file , ciccasefile. show below definition:
<?php namespace app\http\entities\cic; use doctrine\orm\mapping orm; use \carbon\carbon; /** * @orm\entity(repositoryclass="\app\http\repositories\cic\filerepository") * @orm\table(name="files") */ class file { /** * @orm\id() * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") * @var int */ protected $id; /** * @orm\column(type="string") * @var string */ protected $path; /** * @orm\column(type="string") * @var string */ protected $originalname; /** * @orm\column(type="string") * @var string */ protected $hashname; /** * @orm\column(type="string") * @var string */ protected $extension; /** * @orm\onetomany(targetentity="ciccasefile", mappedby="file") */ protected $case_file; /** * @orm\column(type="datetime") * @var datetime */ /** * @orm\column(type="datetime") * @var datetime */ protected $created_at; public function getid(){ return $this->id; } public function setid($id){ $this->id = $id; } public function getpath(){ return $this->path; } public function setpath($path){ $this->path = $path; } public function getoriginalname(){ return $this->originalname; } public function setoriginalname($originalname){ $this->originalname = $originalname; } public function gethashname(){ return $this->hashname; } public function sethashname($hashname){ $this->hashname = $hashname; } public function getextension(){ return $this->extension; } public function setextension($extension){ $this->extension = $extension; } public function getcreatedat() { return $this->created_at; } public function setcreatedat() { $this->created_at = carbon::now(); } }
and:
<?php namespace app\http\entities\cic; use doctrine\orm\mapping orm; use \doctrine\common\collections\arraycollection; use \carbon\carbon; /** * @orm\entity() * @orm\entity(repositoryclass="app\http\repositories\cic\filerepository") */ class ciccasefile { /** * @orm\id * @orm\generatedvalue * @orm\column(type="integer") */ protected $id; /** * * @orm\manytoone(targetentity="ciccase", inversedby="casefiles") * @orm\joincolumn(name="case_id", referencedcolumnname="id") * */ protected $case; /** * * @orm\manytoone(targetentity="file", inversedby="case_file") * @orm\joincolumn(name="file_id", referencedcolumnname="id") */ protected $file; /** * @orm\column(type="integer") */ protected $case_id; /** * @orm\column(type="integer") */ protected $file_id; /** * @orm\column(type="datetime") * @var datetime */ protected $created_at; public function __construct() { //$this->mailboxes = new arraycollection(); } public function setfile($file){ $this->file = $file; } public function getfile(){ return $this->file; } public function setcase($case){ $this->case = $case; } public function getcase(){ return $this->case; } public function getid() { return $this->id; } public function setid($id) { $this->id = $id; } public function getarrayvalues() { return array( 'file_id' => $this->getfile()->getid(), 'case_id' => $this->getcase()->getid(), 'filename' => $this->getfile()->getoriginalname(), //'parentfiles' => $this-> ); } public function getcreatedat() { return $this->created_at; } public function setcreatedat() { $this->created_at = carbon::now(); } }
now i'm trying data left join in way below:
$results = $this->createquerybuilder('f') ->select(['f.hashname', 'f.created_at']) ->innerjoin('f.ciccasefile','cf') ->getquery() ->getarrayresult();
but don't know why dosen't work. have , error:
i don't know what's wrong. how repair that? grateful ;)
Comments
Post a Comment