ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Non-associative array in codeigniter

February 23, 2013 6:06am

Subscribe [2]
  • #1 / Feb 23, 2013 6:06am

    prasenjit

    2 posts

    CodeIgniter always returns associative array from model.
    suppose I want to get “name” from “user_master” table.So i have written the following query in model

    $rows = $this->db->select(‘Name’)
                    ->from(‘user_master’)->get()->result_array();
    And the result is as follows:
    Array
    (
      [0] => Array
          (
            [Name] => Sumanta
          )
    )
    But I want the result as follows

    Array(
    [0]=>Sumanta
    )

    How I’ll will get it?

  • #2 / Feb 23, 2013 9:31am

    johnpeace

    147 posts

    See Jamie Rumbelow’s ‘MY_Model’ class, he has a method that does exactly what you’re describing.

    https://github.com/jamierumbelow/codeigniter-base-model/blob/master/core/MY_Model.php

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases