Jump to content

mysqli multi_query, having problems understanding it.


next

Recommended Posts

I can't figure out how to use this method can anyone help?

For instance i have 2 procedures:

1) CALL get_forums('general'); (headers: forum_id, forum_title, forum_descr)

2) CALL count_threads(); (returns 1, retrieved with 'num_threads')

 

i want to display it like this:

-----

1

-----

title

-----

1

-----

title

-----

etc.

 

i can't figure out how to retrieve info.

Here is my code:

<?php
include('config/config.php');
//include('lib/database.class.php');

$dbh = new mysqli(SERVER, DB_USER, DB_PASSWORD, DB);

$query = "CALL count_threads(); ";
$query .= "CALL get_forums('general');";

$dbh->multi_query($query);
do {
	$result = $dbh->store_result();
	echo $result->fetch_object()->num_threads . '<br />';
	$result->free();

	$dbh->more_results();
	while($result = $dbh->fetch_object())
		echo $result->forum_title . '<br />';

} while($dbh->next_result());
?>

this query displays "1", then throws a fatal error:

Fatal error: Call to undefined method mysqli::fetch_object() in E:\PortableApps\WOS\www\MovieTalk\test.php on line 17

 

 

PHP docs left me really confused  :-\

 

Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.