Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 类函数背靠背_Php_Drupal - Fatal编程技术网

Php 类函数背靠背

Php 类函数背靠背,php,drupal,Php,Drupal,这个方法叫什么?我试图复制这个结果,但我不知道谷歌能找到什么类似的结果来解释。非常感谢您提供有关这方面的任何信息,谢谢。我相信我在Drupals框架中看到了这一点 $query->fields('...')->condition('...')->execute()->fetchAssoc(); 它被称为方法链接。当您的方法返回自身(对象)时: 它被称为方法链接,从php5开始就可以使用。有关更多信息,请查看stackoverflow.com/questions/3724

这个方法叫什么?我试图复制这个结果,但我不知道谷歌能找到什么类似的结果来解释。非常感谢您提供有关这方面的任何信息,谢谢。我相信我在Drupals框架中看到了这一点

$query->fields('...')->condition('...')->execute()->fetchAssoc();

它被称为方法链接。当您的方法返回自身(对象)时:


它被称为方法链接,从php5开始就可以使用。
有关更多信息,请查看stackoverflow.com/questions/3724112/php方法链接

在drupal术语中发生的情况是,将使用“字段”作为输入(select子句),“条件”来过滤获取的记录(where子句)并执行以最终触发查询并以关联数组的形式返回输出。

这是一个常规方法调用,对象恰好是另一个方法的结果。该技术称为方法链接或fluent接口。。。这就是你应该放进谷歌的东西。它主要涉及从方法内部返回
$this
。Propel使用这种方法来构建查询,像jQuery这样的JavaScript框架也是如此。您可能需要一个PHP文档块来在IDE中自动完成,否则,+1。
class testObject
{
   function testMethodOne()
   {
       return $this;
   }

   function testMethodTwo()
   {
       return $this;
   }
}

$obj = new testObject;
$obj->testMethodOne()->testMethodTwo();