我直接进入正题:
Mysql DB tbl = mycars_gallery
|id| car_id|img_thumb |img_link |
-----------------------------------
|5 | 3 |thumb1.jpg|image1.jpg|
|6 | 3 |thumb2.jpg|image2.jpg|
|7 | 3 |thumb3.jpg|image3.jpg|
我有 2 节课:
上传.class.php
class Upload
{
function __construct()
{
// nothing
}
function deleteCarImgs($car_id,$arr_imgids)
{
//weld all img ids and separate by commas
$img_ids = implode(",",$arr_imgids);
$sql = "SELECT img_link, img_thumb ";
.= "FROM mycars_gallery WHERE car_id = :carid AND id IN(:imgids);";
$params = array(
":carid" => $car_id,
":imgids" => $img_ids
);
//DB processing happens in Database class(100% working)
$dbconn = new Database;
$rows = $dbconn->dbProcess($sql, $params); //doesnt run
}
}
汽车类.php
class Cars
{
function __construct()
{
// nothing
}
function deleteCompleteCar(3)//car_id is 3
{
$upload = new Upload();
$arr_imgids = array(5,6,7);//these are img_id = 5,6,7 the ones I want to select
$res = $upload->deleteCarImgs($id,$arr_imgids);
var_dump($res);
}
}
var_dump 消息:
PDOStatement Object ( [queryString] => SELECT img_link, img_thumb FROM mycars_gallery WHERE car_id = :carid AND id IN(:imgids); )
我需要什么: 所有其他功能都正常工作,但对于这个特定的类,它似乎被破坏了。绝对不会发生错误。当我使用 vardump 时,只显示查询,而不是获取图像链接和拇指。我觉得这与 2 个班级之间的互动有关。
我已经做了什么:
- 我已经多次直接运行sql查询,它可以工作
- 我通过其他类运行数据库 PDO 函数,它可以工作
- 我还尝试摆脱 implode() 并将单个数字字符串 '7' 传递给 :imgsid 令牌,仍然没有运气,它实际上返回 NULL,而不是 PDO obj
非常感谢先进。