find Multiple Column in Model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: find Multiple Column in Model (/showthread.php?tid=74873) |
find Multiple Column in Model - ProfessionalCoder - 11-19-2019 I create a category model and ı want to choose three column. but findColumn Method permission this. it's say $column_name should be a name of single column else you will get the DataException. Do you suggest try modify this function public function findColumn(string $columnName) { if (strpos($columnName, ',') !== false) { throw DataException::forFindColumnHaveMultipleColumns(); } $resultSet = $this->select($columnName) ->asArray() ->find(); return (! empty($resultSet)) ? array_column($resultSet, $columnName) : null; } for example public function findColumnAll(array $columnName) { $selectString=""; foreach($columnName as $k=>$v){ $selectString.=$v; } $resultSet = $this->select($selectString) ->asArray() ->find(); return (! empty($resultSet)) ? $resultSet : null; } What do you think About This ??? Does it cause any problem |