简体   繁体   English

TYPO3:exec_SELECTquery with where子句

[英]TYPO3: exec_SELECTquery with where clause

The following select returns an empty result set, although it shoudn't: 以下select返回一个空结果集,尽管它不是:

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_xmluploader_xml_import_tree', 'xml_import_id='.$xml_import_id);

$xml_import_id is set. $xml_import_id已设置。 And it works if I remove the where clause.. 如果我删除where子句,它的工作原理..

Thanks 谢谢


I still don't understand why it doesn't work.. A simple workaround suggested by a coleague: 我仍然不明白为什么它不起作用。一个简单的解决方法由一个coleague建议:

// select all from the db     
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_xmluploader_xml_import_tree');

while( $entry = $GLOBALS['TYPO3_DB']->sql_fetch_assoc() )
{  
   if( $entry['xml_import_id'] == $xml_import_id ) {
      ....
   }    
}

First, make sure the following is set in localconf.php: 首先,确保在localconf.php中设置以下内容:

$TYPO3_CONF_VARS['SYS']['sqlDebug'] = '1';   
$TYPO3_CONF_VARS['FE']['debug'] = '1';  

Then try 然后试试

$res = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_xmluploader_xml_import_tree', 'xml_import_id='.$xml_import_id);
t3lib_div::debug($res);

Result is the output of the query in the frontend. 结果是前端中查询的输出。 You can then execute it in MySQL for debugging. 然后,您可以在MySQL中执行它以进行调试。

a) make sure $xml_import_id actually has a value (one which is in the database as well) a)确保$ xml_import_id实际上有一个值(一个也在数据库中)

b) Try this: b)试试这个:

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
   '*',
   'tx_xmluploader_xml_import_tree',
   "xml_import_id='".$xml_import_id."'"
);

How do you process the result? 你如何处理结果? How does your expected $xml_import_id value look like? 您期望的$ xml_import_id值如何?

cu Roman 罗马

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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