<分区>
我用这个函数调用我的数据库
function get_prescriptionWith_4($ID){
$sql = "SELECT prescriptions FROM tblprescriptions WHERE `ID`='$ID'";
$query = $this->dbh->prepare($sql);
$query->execute();
$row = $query->fetchAll(PDO::FETCH_ASSOC));
return @$row;
}
我的数据库表是这样的..
ID | prescription
1 | Med (gen) 20 -- #20/1X per day --morning--for 30 days/,
1 | test (test) 23 -- #343/1X per day --morning and noon-- 120 days23/,
samp (rere) 44 -- #34/1X per day --morning-- 7 days44/,
1 | asd (asd) 22 -- #222/3X per day --morning noon and evening--30 days/,
qw (wq) 44 -- #222/3X per day --morning noon and evening--60 days/,
1233 (123) 21 -- #123213/1X per day --morning--- 60 days/,
我想要实现的是加载所有具有相同 ID 的处方,并且由于行处方中有多个数据,所以当我尝试使用 时,我使用
我只返回第一个处方我认为使用 fetchAll 可能更好地从我的数据库中获取所有数据..explode
来分隔数据Fetch(PDO::FETCH_ASSOC)
$pres_array3=$patient->get_prescriptionWith_4($ID);
$new_array3=explode(',',$pres_array3,-1);
但是当我使用 echo $new_array3
来检查是否在 fetchAll
上时没有任何返回