We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Return query results and number of rows

Development and Programming

behnampmdg3's avatar
behnampmdg3
136 posts
12 years ago
behnampmdg3's avatar behnampmdg3

Hi;

What is the best way to return query results and number of rows? I do this but I dont really like it

public function list_messages($id)
 {
  $this->db->select('message.content,
  message.clicked,
  message.title,
  message.date_added,
  message.time_added ');
  $this->db->from('message');
  $this->db->where('receiver_ID', $id);
  $query = $this->db->get();
  $results[] = $query->result();
  $results['rows'] = $query->num_rows();
  return $results;
 }
       
PravinS's avatar
PravinS
123 posts
12 years ago
PravinS's avatar PravinS

return $query then

       
behnampmdg3's avatar
behnampmdg3
136 posts
12 years ago
behnampmdg3's avatar behnampmdg3
return $query then

Sweet like apple juice

       
behnampmdg3's avatar
behnampmdg3
136 posts
12 years ago
behnampmdg3's avatar behnampmdg3
return $query then

But this doesnt work:

$query = $this->db->get();

Doesnt return results!

$sql = "SELECT ...WHERE ad_have.member_ID = ? AND ad_have.id = ?";
$query = $this->db->query($sql, $details); 
print_r($query);
//prints
CI_DB_mysql_result Object
(
    [conn_id] => Resource id #29
    [result_id] => Resource id #36
    [result_array] => Array
        (
        )

    [result_object] => Array
        (
        )

    [custom_result_object] => Array
        (
        )

    [current_row] => 0
    [num_rows] => 1
    [row_data] => 
)
       
LiveWire's avatar
LiveWire
4 posts
12 years ago
LiveWire's avatar LiveWire

Simple and effective!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.