改进Collection类的column方法

This commit is contained in:
thinkphp
2017-05-18 14:26:08 +08:00
parent 8cc44f8bf6
commit 993cda07a6

View File

@@ -16,6 +16,20 @@ use think\Model;
class Collection extends BaseCollection
{
/**
* 返回数组中指定的一列
* @param string $column_key
* @param string|null $index_key
* @return array
*/
public function column($column_key, $index_key = null)
{
if (function_exists('array_column')) {
return array_column($this->toArray(), $column_key, $index_key);
}
return parent::column($column_key, $index_key);
}
/**
* 延迟预载入关联查询
* @access public