From 993cda07a619d34735e36111cca94a6da7593067 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 18 May 2017 14:26:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BCollection=E7=B1=BB=E7=9A=84c?= =?UTF-8?q?olumn=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/Collection.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/think/model/Collection.php b/library/think/model/Collection.php index 08e11ad8..4e4bb4dc 100644 --- a/library/think/model/Collection.php +++ b/library/think/model/Collection.php @@ -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