我有一个数组 $ziparray,我试图在 MySQL 查询中使用它来检查名为“zip”的数据库列。以下代码对我来说似乎是合乎逻辑的,但出现错误:
可捕获的致命错误:stdClass 类的对象无法在...中转换为字符串
$ziparrayimplode = implode(",", $ziparray);
$listinghistoryquery = "SELECT * FROM listings WHERE zip IN ($ziparrayimplode) ORDER BY list_ts DESC";
$listinghistory = mysql_query($listinghistoryquery) or die('SQL Error :: '.mysql_error());
我绝对确定 $ziparray 是一个数组。谁能告诉我如何使这个查询工作?这是用于创建数组的代码..
$countyzipquery = mysql_query("SELECT city_zip FROM dev_cities WHERE city_state='$state' AND city_county='$county' AND city_name='$city'");
$ziparray = array();
while (($ziparrayrow = mysql_fetch_object($countyzipquery)) !== FALSE) {
$ziparray[] = $ziparrayrow;
这是 var_dump($ziparray) 的输出
array(1) { [0]=> object(stdClass)#3 (1) { ["city_zip"]=> string(5) "63028" } }