简体   繁体   中英

PHP My query is working in phpmyadmin but not in my code

So i made use this query to get the details about changes and mail it. It previously worked when the seconde inner join was missing but what ever i do i cant make it work with it. In phpmyadmin it works and i get my rows but in my php i get 0 rows. i would love to know what im doing wrong here.

$query = "SELECT * FROM vtiger_modtracker_detail WHERE id = (SELECT vtiger_modtracker_detail.id FROM vtiger_modtracker_detail " .
"INNER JOIN vtiger_modtracker_basic ON vtiger_modtracker_basic.id = vtiger_modtracker_detail.id " .
"INNER JOIN vtiger_crmentity ON vtiger_crmentity.modifiedtime = vtiger_modtracker_basic.changedon " .
"WHERE vtiger_crmentity.crmid = ? ORDER BY vtiger_modtracker_detail.id DESC LIMIT 1);";

$res = $adb->pquery($query, array($id[1]));
$row = $adb->num_rows($res);

EDIT:

I simplified the query a bit but nothing changed.

$query = "SELECT * FROM vtiger_modtracker_detail WHERE id = (SELECT vtiger_modtracker_basic.id FROM vtiger_modtracker_basic " .
"INNER JOIN vtiger_crmentity ON vtiger_crmentity.modifiedtime = vtiger_modtracker_basic.changedon " .
"WHERE vtiger_crmentity.crmid = 42 ORDER BY vtiger_modtracker_basic.id DESC LIMIT 1)";

It could be because im comparing dates in the INNER JOIN.

EDIT 2: missing $ at pquery() but this did not fix it. I have found a work around so i dont need to use this query anymore. but if someone does know whats wrong with the query i would love to know.

EDIT 3: Work around did not work Still need an answer on this.

在查询中的每个名称前添加'

SELECT 'vtiger_modtracker_detail.id' FROM 'etc', 'etc2'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM