以下代码运行良好,但该行$connection->query('call user_create(145552, \'a@a.com\');');
并未在数据库中创建用户。
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, \'a@a.com\');');
}
$connection->close;
$json = json_encode(array(
'r' => true
));
echo $json;
}
如果我运行以下代码,它也可以正常工作:
$connection = mysqli_connect('localhost', 'root', '', 'databasename');
$connection->query('call user_create(145552, \'a@a.com\');');
$connection->close;
如果我$count
在 user_create 调用之前关闭连接并再次打开它,它也可以工作。
怎么了?