コード例 #1
0
 /**
  * Returns the fragment SQL
  *
  * @param   rdbms.DBConnection conn
  * @return  string
  * @throws  rdbms.SQLStateException
  */
 public function asSql(DBConnection $conn)
 {
     if (JoinProcessor::isJoinContext()) {
         return JoinProcessor::pathToKey($this->path) . '.' . $this->name;
     }
     return $this->name;
 }
コード例 #2
0
 public function multipleJoinResultTest()
 {
     $rs = new MockResultSet(array(array(JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Schultz', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '21', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '12', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Müller', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '12', JoinProcessor::FIRST . '_title' => 'second job', JoinProcessor::FIRST . '_valid_from' => new Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Schultz', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '21', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '13', JoinProcessor::FIRST . '_title' => 'third job', JoinProcessor::FIRST . '_valid_from' => new Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => NULL, JoinProcessor::pathToKey(array('PersonJob')) . '_name' => NULL, JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => NULL, JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => NULL)));
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(array('PersonJob' => 'join'));
     $ji = new JoinIterator($jp, $rs);
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertFalse($pji->hasNext());
     $this->assertFalse($ji->hasNext());
 }
コード例 #3
0
 public function testJoinWithProjection()
 {
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(array('PersonJob->Department' => 'join'));
     $jp->enterJoinContext();
     $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', create(new Criteria())->setFetchmode(Fetchmode::join('PersonJob'))->setProjection(Projections::ProjectionList()->add(Job::column('PersonJob->job_id'))->add(Job::column('PersonJob->Department->department_id')))->getSelectQueryString($this->conn, $this->peer, $jp));
     $jp->leaveJoinContext();
 }
コード例 #4
0
 public function noSuchRoleTest()
 {
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(array('UnknowenRole' => 'join'));
 }