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


PHP DataList::sql方法代码示例

本文整理汇总了PHP中DataList::sql方法的典型用法代码示例。如果您正苦于以下问题:PHP DataList::sql方法的具体用法?PHP DataList::sql怎么用?PHP DataList::sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataList的用法示例。


在下文中一共展示了DataList::sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testNoSpecificColumnNamesSubclassDataObjectQuery

 public function testNoSpecificColumnNamesSubclassDataObjectQuery()
 {
     // This queries all columns from base table and subtable
     $playerList = new DataList('DataObjectTest_SubTeam');
     // Should be a left join.
     $this->assertEquals(1, preg_match($this->normaliseSQL('/SELECT DISTINCT .* LEFT JOIN .* /'), $this->normaliseSQL($playerList->sql($parameters))));
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:7,代码来源:DataObjectLazyLoadingTest.php

示例2: getKey

 /**
  * @return string
  */
 public function getKey()
 {
     return md5($this->list->sql());
 }
开发者ID:heyday,项目名称:silverstripe-redirects,代码行数:7,代码来源:DataListDataSource.php

示例3: attachToMoreRelevantHasOne

 /**
  * Usage: Find the copied ("NEW") equivalent of the old has-one relation and attach it to the newObject ...
  * @param DataObject $copyFrom
  * @param DataObject $newObject
  * @param String $hasOneMethod - the fieldname (method) of the has one relations (e.g. MyOtherDataObject)
  * @param DataList $dataListToChooseFrom
  *
  * @return CopyFactory
  */
 public function attachToMoreRelevantHasOne($copyFrom, $newObject, $hasOneMethod, $dataListToChooseFrom)
 {
     $fieldNameWithID = $hasOneMethod . "ID";
     if ($this->recordSession) {
         self::add_to_session("\n\t\t\t\t\t====================================\n\t\t\t\t\tATTACH TO MORE RELEVANT HAS-ONE\n\t\t\t\t\tFIELD {$hasOneMethod}\n\t\t\t\t\tOBJECTS TO CHOOSE FROM: " . $dataListToChooseFrom->sql() . "\n\t\t\t\t\t====================================\n\t\t\t\t", $copyFrom, $newObject);
     }
     if ($copyFrom->{$fieldNameWithID}) {
         //find out field to choose from
         $firstObject = $dataListToChooseFrom->first();
         if ($firstObject) {
             $dataListToChooseFrom = $dataListToChooseFrom->filter(array($firstObject->CopiedFromFieldName($withID = true) => $copyFrom->{$fieldNameWithID}))->Sort("Created DESC");
             $count = $dataListToChooseFrom->count();
             if ($count == 1 && ($newAttachment = $dataListToChooseFrom->First())) {
                 if ($this->recordSession) {
                     self::add_to_session("Found Matching record.", $copyFrom, $newObject);
                 }
                 if ($this->isForReal) {
                     $newObject->{$fieldNameWithID} = $newAttachment->ID;
                     $newObject->write();
                 }
             } else {
                 if ($this->recordSession) {
                     if ($count > 1) {
                         self::add_to_session("ERROR: found too many Matching records.", $copyFrom, $newObject);
                     } elseif ($count == 0) {
                         self::add_to_session("ERROR: Could not find any Matching records.", $copyFrom, $newObject);
                     } else {
                         self::add_to_session("ERROR: There was an error retrieving the matching record.", $copyFrom, $newObject);
                     }
                 }
                 if ($this->isForReal) {
                     $newObject->{$fieldNameWithID} = 0;
                     $newObject->write();
                 }
             }
         } else {
             self::add_to_session("ERROR: Could not find any Matching records from base DataList.", $copyFrom, $newObject);
             $newObject->{$fieldNameWithID} = 0;
             $newObject->write();
         }
     } else {
         if ($this->recordSession) {
             self::add_to_session("copyFrom object does not have a value for: {$fieldNameWithID}", $copyFrom, $newObject);
         }
     }
     if ($this->recordSession) {
         self::add_to_session("*** END OF attachToMoreRelevantHasOne ***", $copyFrom, $newObject);
     }
     return $this;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-copyfactory,代码行数:59,代码来源:CopyFactory.php


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