Welcome Guest, Not a member yet? Register   Sign In
how ican converte stdClass Object to string
#1

[eluser]kosaidpo[/eluser]
hello everyone i guess all in the title well

this how i proceed
when i do this kind of sql query
Code:
SELECT id_forum ,nom_forum ,descri_forum ,
count(id_post) AS NbrDiscussion ,
count(id_reply) AS NbrMessage ,
content_post ,reply_by ,post_by    ,
title_post ,content_reply
FROM t_forum LEFT JOIN posts ON
t_forum.id_forum=posts.id_forum_post
LEFT JOIN users  ON  users.id_user=posts.id_user_post
LEFT JOIN replies ON replies.id_user_reply=users.id_user
GROUP BY id_forum

and i use the html class table it gives me a message sayin could not convert std class object to string i ve looked around the Doc but icudnt find anythin i can do with this class to convert it

tnx for replies in advance : )
#2

[eluser]kosaidpo[/eluser]
okay i 've found it i shud return the query as an array usin result_array()

if anyone knows sumthin better post it please

kosaidpo
#3

[eluser]danmontgomery[/eluser]
There is a way to "convert" stdClass to a string (the __toString method), but that's not what you need here. The problem is that you're passing a function an object ( I'm guessing you're directly passing $query->result() ), when the function is expecting a string.
#4

[eluser]kosaidpo[/eluser]
i really dont get you im new to CI but here's wht i did

in model
Code:
$Q=query bla bla here ;

if(Q->num_rows > 0)
{
foreach($Q->aray_result() as $row)
{
$data=$row ;
}

}
return $data ;
in controller
Code:
$res['r']=callin the model_methode
loadin the view with $res
and displayin it with the html table




Theme © iAndrew 2016 - Forum software by © MyBB