本文整理汇总了PHP中SQLQuery::addSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::addSelect方法的具体用法?PHP SQLQuery::addSelect怎么用?PHP SQLQuery::addSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::addSelect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: augmentSQL
/**
* @param SQLQuery $query
*/
public function augmentSQL(SQLQuery &$query)
{
$address = Controller::curr()->getRequest()->getVar('Address');
if ($this->owner->hasMethod('updateAddressValue')) {
$address = $this->owner->updateAddressValue($address);
}
if ($address) {
// on frontend
$coords = GoogleGeocoding::address_to_point($address);
$Lat = $coords['lat'];
$Lng = $coords['lng'];
$query->addSelect(array('( 3959 * acos( cos( radians(' . $Lat . ') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians(' . $Lng . ') ) + sin( radians(' . $Lat . ') ) * sin( radians( `Lat` ) ) ) ) AS distance'));
}
}
示例2: getAdminPermissionSet
function getAdminPermissionSet(array &$res)
{
$companyId = $_REQUEST["CompanyId"];
if (isset($companyId) && is_numeric($companyId) && $companyId > 0) {
// user could be ccla admin of only one company and company must have at least one team set
$ccla_group = Group::get()->filter('Code', ICLAMember::CCLAGroupSlug)->first();
if (!$ccla_group) {
return;
}
$query_groups = new SQLQuery();
$query_groups->addSelect("GroupID");
$query_groups->addFrom("Company_Administrators");
$query_groups->addWhere("MemberID = {$this->owner->ID} AND CompanyID <> {$companyId} AND GroupID = {$ccla_group->ID} ");
$groups = $query_groups->execute()->keyedColumn();
$company = Company::get()->byID($companyId);
if (count($groups) === 0 && $company->isICLASigned()) {
array_push($res, 'CCLA_ADMIN');
}
}
}
示例3: testSelect
public function testSelect()
{
$query = new SQLQuery('"Title"', '"MyTable"');
$query->addSelect('"TestField"');
$this->assertEquals('SELECT "Title", "TestField" FROM "MyTable"', $query->sql());
// Test replacement of select
$query->setSelect(array('Field' => '"Field"', 'AnotherAlias' => '"AnotherField"'));
$this->assertEquals('SELECT "Field", "AnotherField" AS "AnotherAlias" FROM "MyTable"', $query->sql());
// Check that ' as ' selects don't get mistaken as aliases
$query->addSelect(array('Relevance' => "MATCH (Title, MenuTitle) AGAINST ('Two as One')"));
$this->assertEquals('SELECT "Field", "AnotherField" AS "AnotherAlias", MATCH (Title, MenuTitle) AGAINST (' . '\'Two as One\') AS "Relevance" FROM "MyTable"', $query->sql());
}
示例4: getRemoteObjectsQuery
/**
* @return SQLQuery
*/
protected function getRemoteObjectsQuery()
{
// Get all tables to query
$tables = $this->getRemoteClassHierarchy();
$baseClass = array_shift($tables);
// Generate sql query
$query = new SQLQuery("\"{$baseClass}\".*", "\"{$baseClass}\"", $this->targetWhere);
$query->setOrderBy("\"{$baseClass}\".\"ID\" ASC");
// Sort by ID for some performance reasons
foreach ($tables as $class) {
$query->addSelect("\"{$class}\".*");
$query->addLeftJoin($class, "\"{$baseClass}\".\"ID\" = \"{$class}\".\"ID\"");
}
return $query;
}