dropdown from database |
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()
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()
|
Welcome Guest, Not a member yet? Register Sign In |