Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,660
    Rep Power
    4123
    Having read the docs, and not seen the entire of his codebase I have assumed that zxcvbnm has added in the row count manually - I can't believe a framework would do such a thing - or if it did, meta data such as the row count would be accessed under a different index, eg

    $data['data'][0-n]
    and
    $data['meta']['rows']
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,868
    Rep Power
    368
    yes he has, if you look at the first post (I think) he gets an object i.e.

    $result => get_objects();
    $result[row_count] = mysql_affected_rows();

    he is doing this because there might be a limitation of codeigniter/function that you cannot return two things at once.

    HOWEVER (untested) and in normal OOP way (if it applies to CI models) could you not have a variable at the TOP.. so a rough code (forgotten CI exact syntax)
    PHP Code:
    model  Test {

          public   
    row_count "";

          function   
    whatever(){
                 do 
    the sql;
                 
    get the results in an object called $result
                 $this
    ->row_count mysql_affected_rows(); 
          }


    then in your controller could you not do
    $this->test->row_count;....
  4. #18
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Nobbies beach, Gold Coast. It's beautiful.
    Posts
    2,568
    Rep Power
    171
    Ok, I found a solution. CI is doing a better job than I thought! Eventhough it looks strange but it does what I need. Long story short:
    PHP Code:
    $data['messages'] = $data['messages']->result_array 
    Long story long:
    PHP Code:
    //Model
    $query $this->db->get();
    return 
    $query
    PHP Code:
    $data['messages'] = $this->model_ads->list_messages($this->session->userdata['logged_data']['member_id']);
    print_r($data['messages']); 
    Prints:
    Code:
    CI_DB_mysql_result Object
    (
        [conn_id] => Resource id #29
        [result_id] => Resource id #39
        [result_array] => Array
            (
                [0] => Array
                    (
                        [message_id] => 52484
                        [content] => Hi we have a room in Broadbeach $170 per week. We are an English couple. We are quite chilled and easy going so not party animals please.
    We love cooking and are into healthy living. contact us on **** or 0***33375
                        [clicked] => n
                        [title] => I'm intrested in your Ad
                        [date_added] => 2012-07-04
                        [time_added] => 3:28 pm
                    )
    
                [1] => Array
                    (
                        [message_id] => 52153
                        [content] => Hey guys,
    I'm interested in finding out more about this place! Please feel free to contact me on 0450###615.
    
    Thanks!!
                        [clicked] => y
                        [title] => Let's move in together
                        [date_added] => 2012-02-22
                        [time_added] => 1:30 pm
                    )
    
            )
    
        [result_object] => Array
            (
            )
    
        [custom_result_object] => Array
            (
            )
    
        [current_row] => 0
        [num_rows] => 2
        [row_data] => 
    )
    Whole process
    PHP Code:
    $this->load->model('model_ads');
                
    $data['messages'] = $this->model_ads->list_messages($this->session->userdata['logged_data']['member_id']);
                foreach(
    $data['messages']->result_array as $val =>$row)
                    {
                        
                        if(
    $row['clicked']!='y')
                            {
                                ++
    $this->unread;
                            }
                    }
                
    $data['messages'] = $data['messages']->result_array;    
                
    $data['unread'] = $this->unread;
                
    $this->load->view('view_header'$data);
                
    $this->load->view('view_account'$data);
                
    $this->load->view('view_footer'); 
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo