function propertyListAliasTest() { $this->assertProjection('job_id as `id`, title', 'job_id as \'id\', title', 'job_id as "id", title', 'job_id as \'id\', title', create(new \rdbms\Criteria())->setProjection(Projections::projectionList()->add(Projections::property(Job::column('job_id')), 'id')->add(Job::column('title')))); }
/** * Set projection * param can also be a rdbms.Column, a property * If the first parameter is omitted or NULL given the projection will be cleared * projection is then assumed * * @param rdbms.SQLRenderable projection optional * @param string optional alias * @return rdbms.Criteria this object */ public function setProjection(SQLRenderable $projection = null, $alias = '') { $this->projection = is_null($projection) || $projection instanceof ProjectionList ? $projection : ($projection = Projections::projectionList()->add($projection, $alias)); return $this; }
public function testJoinWithProjection() { $jp = new \rdbms\join\JoinProcessor(Job::getPeer()); $jp->setFetchModes(['PersonJob->Department' => 'join']); $jp->enterJoinContext(); try { $this->assertEquals('select PersonJob.job_id, PersonJob_Department.department_id from JOBS.job as start, JOBS.Person as PersonJob, JOBS.Department as PersonJob_Department where start.job_id *= PersonJob.job_id and PersonJob.department_id *= PersonJob_Department.department_id and 1 = 1', (new Criteria())->setFetchmode(\rdbms\join\Fetchmode::join('PersonJob'))->setProjection(\rdbms\criterion\Projections::projectionList()->add(Job::column('PersonJob->job_id'))->add(Job::column('PersonJob->Department->department_id')))->getSelectQueryString($this->conn, $this->peer, $jp)); } finally { $jp->leaveJoinContext(); } }