PHP SQL查询Where返回null

时间:2018-01-22 19:23:00

标签: php sql json where

//get coins
$json = file_get_contents('https://api.coinmarketcap.com/v1/ticker/?limit=0');
$coins = json_decode($json, true);

for ($i=0; $i < count($coins) ; $i++) { 
    $id[] = "'".$coins[$i]["id"]."'";
}

$impId = implode(',',$id);

$getCoins = $this->code = $this->conn->prepare("SELECT * FROM coins WHERE id_name IN (?)");
$getCoins = $this->code->bind_param('s', $impId);
$getCoins = $this->code->execute();
$getCoins = $this->code->get_result();
var_dump($getCoins);

我从数据库中获取记录(表:coins) 函数var_dump($getCoins);返回:

  

object(mysqli_result)#4(5){[&#34; current_field&#34;] =&gt; INT(0)   [&#34;场计数&#34;] =&GT; int(16)[&#34; length&#34;] =&gt; NULL [&#34; num_rows&#34;] =&gt; INT(0)   [&#34;类型&#34;] =&GT; int(0)}

变量$impId返回字符串:

  

&#39;比特币&#39;&#39;复仇&#39;&#39;波纹&#39;,&#39;比特币现金&#39;&#39;卡尔达诺&#39 ;, &#39;莱特币&#39;&#39; NEM&#39;&#39; EOS&#39;&#39;恒星&#39;

我不知道为什么我num_rows = 0,在数据库中我有2行:

enter image description here

0 个答案:

没有答案