本文整理匯總了PHP中DboSource::buildJoinStatement方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::buildJoinStatement方法的具體用法?PHP DboSource::buildJoinStatement怎麽用?PHP DboSource::buildJoinStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::buildJoinStatement方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGenerateAssociationQueryBelongsToWithConditions
/**
* testGenerateAssociationQueryBelongsToWithConditions method
*
* @return void
*/
public function testGenerateAssociationQueryBelongsToWithConditions() {
$this->Model = new TestModel5();
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$binding = array('type' => 'belongsTo', 'model' => 'TestModel4');
$queryData = array('conditions' => array('TestModel5.name !=' => 'mariano'));
$resultSet = null;
$null = null;
$params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding);
$result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet);
$this->assertTrue($result);
$testModel4Table = $this->Dbo->fullTableName($this->Model->TestModel4, true, true);
$result = $this->Dbo->buildJoinStatement($queryData['joins'][0]);
$expected = ' LEFT JOIN ' . $testModel4Table . ' AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)';
$this->assertEquals(trim($expected), trim($result));
$result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
$this->assertRegExp('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`, `TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result);
$this->assertRegExp('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+LEFT JOIN\s+\S+`test_model4` AS `TestModel4`/', $result);
$this->assertRegExp('/\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE\s+/', $result);
$this->assertRegExp('/\s+WHERE\s+`TestModel5`.`name` != \'mariano\'\s*$/', $result);
}