• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.