![]() |
20.03.19 Message: Object of class stdClass could not be converted to string - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: 20.03.19 Message: Object of class stdClass could not be converted to string (/showthread.php?tid=73109) |
20.03.19 Message: Object of class stdClass could not be converted to string - Porto - 03-20-2019 Hello Guys, please i need a Light! I've already read some cases identical as my issue here in the Forum, but i don't get STILL see what should i do. The best answer was: ------------------------------------------------------- eluser]Massaki[/eluser] The variable $var is an object. If you want to show an attribute from the object, then Code: echo $var->name_of_the_attribute ------------------------------------------------------- But i still stuck. I'm using this block of code from the documentation: https://www.codeigniter.com/user_guide/database/results.html#result-rows This is my Controller/Method _____________________________ Code: public function votecounting($page = 'vote_detail1') This is my Model _____________________________ Code: public function totalparticipants() This is my VIEW _____________________________ Code: <div class="XXX"> If i try to show the variable this way: <?php echo $totalrows; ?> i got the error message. Code: A PHP Error was encountered If i try to show the variable this way: <?php echo $totalrows->v_id; ?> i got the error message. Code: A PHP Error was encountered This is the result of my First print_r() <?php print_r($totalrows); ?> _____________________________ Code: Votes stdClass Object ( [count(v_id)] => 498 ) This is the result of my Second print_r() <?php print_r($totalrows); ?> _____________________________ Code: The number who participated in the Vote yet stdClass Object ( [count(v_id)] => 498 ) 1 VOTER What should i do please? v_id is the table_field_id and i just want to show a single row as explained in the documentation. i've already tried using row_array(), But i stuck the same way. Thank you so much in advance! RE: 20.03.19 Message: Object of class stdClass could not be converted to string - InsiteFX - 03-20-2019 SEE: CodeIgniter User's Guide - Generating Query Results RE: 20.03.19 Message: Object of class stdClass could not be converted to string - Porto - 03-20-2019 (03-20-2019, 03:54 AM)InsiteFX Wrote: SEE: Hello InsiteFX, I thank you to send me back to the documentation, but, unfortunatly this doens't helped me! This is the Standardt error that i get! PHP Code: A PHP Error was encountered I know that it would be such a ridiculous question, but i need to ask anyway because there is no ridiculous question in this world. This is the first example from CI documentation - Result Arrays Where should go where please? The first line belongs to the CI Model file: Code: 1° $query = $this->db->query("YOUR QUERY"); Where should go this "foreach" please? Does it work together with the line above in the same file "model file" or does he go to the view file? Code: foreach ($query->result() as $row) I will try to practice every example from the Database Reference page, https://www.codeigniter.com/user_guide/database/index.html because if you just are not programmer 25 hours a day, it comes a moment that you forget the simple things. Thank you! SOLVED: 20.03.19 Message: Object of class stdClass could not be converted to string - Porto - 03-20-2019 (03-20-2019, 04:19 AM)Porto Wrote:(03-20-2019, 03:54 AM)InsiteFX Wrote: SEE: Issue Solved on 20.03.2019 13:59 The Problem was the lack of a index in the Query (CI Model File). SELECT count(v_id) AS v_id FROM RE: 20.03.19 Message: Object of class stdClass could not be converted to string - Porto - 03-20-2019 SOLVED ISSUE |