Welcome Guest, Not a member yet? Register   Sign In
dropdown from database
#2

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()
{
    $builder $this->db->table('units');
    $query $builder->select('unit_id, unit_name')->get();

    $data = [];

    if ($query) {
        foreach ( $query->getResultArray() as $row ) {
            $data [$row ['unit_id']] = $row ['unit_name'];
        }
    }

    $query->freeResult();

    return $data;

Reply


Messages In This Thread
dropdown from database - by antiserious - 12-12-2020, 03:14 PM
RE: dropdown from database - by vitnibel - 12-12-2020, 08:59 PM
RE: dropdown from database - by antiserious - 12-13-2020, 01:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB