Reputation: 4390
The following code is working just fine, but the line $connection->query('call user_create(145552, \'[email protected]\');');
is not creating a user into the database.
function updateFacebook($id) {
$connection = mysqli_connect('localhost', 'root', '', 'databasename');
$count = $connection->query('call user_by_facebook_read(' . $id . ');')->num_rows;
if ($count == 0) {
$request = \Slim\Slim::getInstance()->request();
$body = $request->getBody();
$json = json_decode($body);
$token = $json->token;
$facebook = new Facebook(array(
'appId' => 'value',
'secret' => 'value',
'cookie' => true
));
$facebook->setAccessToken($token);
$facebook->api('/me/feed', 'post', array(
'message' => 'message',
'picture' => 'https://www.google.com.br/images/srpr/logo4w.png',
'link' => 'https://www.google.com.br',
'description' => 'description',
'name' => 'name',
'caption'=> 'caption'
));
$connection->query('call user_create(145552, \'[email protected]\');');
}
$connection->close;
$json = json_encode(array(
'r' => true
));
echo $json;
}
If I run the following code it also works just fine:
$connection = mysqli_connect('localhost', 'root', '', 'databasename');
$connection->query('call user_create(145552, \'[email protected]\');');
$connection->close;
If I close the connection after the $count
and open it again before the user_create call it also works.
What is happening?
Upvotes: 0
Views: 61
Reputation: 70490
You need to run ->close()
on the result, but you discarded that. So:
$result = $connection->query(..);
$count = $result->num_rows;
$result->close();
and after CALL()s in MySQLi it seems to need this:
$connection->next_result();
Upvotes: 1