![]() |
dropdown from database - 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: dropdown from database (/showthread.php?tid=78196) |
dropdown from database - antiserious - 12-12-2020 Model: public function getAllUnitsDropDown() { $builder = $this->db->table('units'); $query = $builder->select('unit_id, unit_name'); if ($query->countAll() > 0) { foreach ( $query->getResultArray() as $row ) { $data [$row ['unit_id']] = $row ['unit_name']; } } $query->free_result (); return $data; } result: Error Call to undefined method CodeIgniter\Database\MySQLi\Builder::getResultArray() RE: dropdown from database - vitnibel - 12-12-2020 Hi. You forgot to call function get() after select() and you don't need to call countAll() function to check if the request was successful. PHP Code: public function getAllUnitsDropDown() RE: dropdown from database - antiserious - 12-13-2020 Thanks.its works. |