From php.net reference:
The value being encoded. Can be any type except a resource.
This function only works with UTF-8 encoded data.
However, I use the function like this in one case which works fine:
$result_array = $this->DatabaseObject->_pdoQuery( 'multiple', 'bookmark_model', array( $this->SessionObject->get( 'id' ) ) );
$result_string = json_encode( $result_array );
$html_string = "<div id='bookmark_data'>" . $result_string . "</div>";
echo $html_string;
But in this case it does not:
$result_array = $this->DatabaseObject->_pdoQuery( 'multiple', 'tweet_model' );
// $tweet_object = new MarkTweet();
$result_string = json_encode( $result_array );
$html_string = "<div id='tweet_data'>" . $result_string . "</div>";
echo $html_string;
In both cases I’m using PDO library to query the database. I know I get back what should be essentially an array of arrays…but I don’t know if this is resource or not…or how it is structured internally.
There is no major difference between the queries that I can see…here they are though. Because the two cases are so similar I don’t know what is causing the fail.
Here are the queries
"bookmark_model" => "SELECT * FROM bookmarks WHERE id=? ORDER BY tag, title",
"tweet_model" => "SELECT * FROM tweets ORDER BY time DESC LIMIT 7",
It looks like your _pdoQuery() function returns different types in different situations. You may want to check to make sure you got a successful result before trying to encode it.