Welcome Guest, Not a member yet? Register   Sign In
How to strtolower all query result keys
#11

[eluser]skunkbad[/eluser]
Third and last, MY_CI_DB_mysqli_result.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_CI_DB_mysqli_result extends CI_DB_mysqli_result {

    function result_array()
    {
        if (count($this->result_array) > 0)
        {
            return $this->result_array;
        }

        // In the event that query caching is on the result_id variable
        // will return FALSE since there isn't a valid SQL resource so
        // we'll simply return an empty array.
        if ($this->result_id === FALSE OR $this->num_rows() == 0)
        {
            return array();
        }

        $this->_data_seek(0);
        while ($row = $this->_fetch_assoc())
        {
            $this->result_array[] = $row;
        }

        foreach ($this->result_array as $key => $value) {
            if (is_array($value)) {
                $this->result_array[$key] = array_change_key_case($value);
            }
        }

        return $this->result_array;
    }

}
#12

[eluser]skunkbad[/eluser]
So, those three files don't show the final functionality, but for anyone who wants to extend the database drivers, you can modify these files to suit your needs. Obviously, I'm using mysqli. All files live in application/core.




Theme © iAndrew 2016 - Forum software by © MyBB