MySQL DB& PHP - 选择Query不能使用PHP,但可以在MySQL WorkBench中使用

时间:2014-04-09 21:27:55

标签: php mysql sql

尝试通过PHP脚本查询MySQL数据库。

SELECT i.id issues_id, i.project_id, i.tracker_id, t.name tracker_name, i.subject,  
       i.author_id, i.assigned_to_id, u1.firstname tfirst, u1.lastname tlast, 
       u2.firstname dfirst, u2.lastname dlast, i.updated_on, cast(i.updated_on as DATE)
       updated_date, ist.name istatusname, concat(u1.lastname, ', ', u1.firstname) Tname, 
       concat(u2.lastname, ', ', u2.firstname) Dname
FROM issues i, trackers t, users u1, users u2, issue_statuses ist
WHERE i.tracker_id = t.id AND 
      i.author_id = u1.id AND 
      i.assigned_to_id = u2.id AND 
      ist.id = i.status_id AND 
      concat(u1.lastname, ', ', u1.firstname) like '%' AND 
      concat(u2.lastname, ', ', u2.firstname) like '%' AND 
      t.name like '%' AND 
      ist.name like '%' AND 
      cast(i.updated_on as DATE) BETWEEN '2008-01-01' AND '2015-01-01';

当我在MySQL WorkBench中运行sql代码时,这非常正常 但是,当我尝试通过PHP运行时,我得到零结果。

问题似乎源于这条线:

ist.name like '%'

当我省略这部分代码时,它会在MySQL WorkBench和PHP脚本中按预期运行(包括在引号内尝试其他值)。
添加该部分,无论我将什么作为值,通过PHP脚本给出零结果。


受欢迎的需求,
相关的PHP代码:

$result = mysqli_query($con,"
--SQL CODE HERE--
");


while($row = mysqli_fetch_array($result))
{
echo '<td>' . $row['issues_id'] . '</td>';
--ECHO COLUMNS HERE--
}

问题是什么???

0 个答案:

没有答案