rgin
rgin

Reputation: 2311

CodeIgniter Active Record - return a non-associative array as result

Is there a way to return a non-associative array as a result of a CI db query? Say, I have this table:

id | Name
 1 | Name1
 2 | Name2
 3 | Name3
 4 | Name4

I want the names to be returned as a non-associative array.

$this->db->select('tablename')->result_array() returns an associative array.

Is this even possible in CI? I don't want to have to add an extra foreach statement if it is.

Please shed some light.

Upvotes: 2

Views: 3784

Answers (2)

nageeb
nageeb

Reputation: 2042

You could just use array_values(), which returns an array containing the values of your associative array.

Upvotes: 3

mic
mic

Reputation: 1273

There is no built in function for this (or at least i have never seen any), I would suggest using another function for this using your foreach loop method.

There may be other ways I would suggest looking on the CI forums, im sure some else has had this problem before.

Sorry i can't be anymore help.

Upvotes: 1

Related Questions