Welcome Guest, Not a member yet? Register   Sign In
I added new function in DB_result.php
#1

[eluser]Atas[/eluser]
I added this function in DB_result.php

Code:
function result_with_table_name() {
       $result = $this->result_id;
      
        $i=0;
        while ($i < mysql_num_fields($result)) {          
            $fields[]=mysql_fetch_field($result, $i);
            $i++;
        }
      
        while ($row=mysql_fetch_row($result)) {              
            $new_row=array();
            for($i=0;$i<count($row); $i++) {
                $new_row[$fields[$i]->table.".".$fields[$i]->name]=$row[$i];
            }
            $return[]=$new_row;
        }
        
        return $return;
    }

This function returns an array joining the table name and field name. This is very useful when we need to use "SQL JOIN" and some fields has the same name. Does codeigniter have already a similar function?




Theme © iAndrew 2016 - Forum software by © MyBB