当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLQuery::addSelect方法代码示例

本文整理汇总了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'));
     }
 }
开发者ID:dynamic,项目名称:silverstripe-locator,代码行数:17,代码来源:DistanceDataExtension.php

示例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');
         }
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:20,代码来源:ICLAMemberDecorator.php

示例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());
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:12,代码来源:SQLQueryTest.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:tractorcow-silverstripe-legacyimport,代码行数:18,代码来源:DataObjectImporter.php


注:本文中的SQLQuery::addSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。