TYPO3:带有 where 子句的 exec_SELECTquery

发布于 2024-12-08 07:48:07 字数 612 浏览 0 评论 0原文

以下 select 返回一个空结果集,尽管它不应该:

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

$xml_import_id 已设置。如果我删除 where 子句,它就会起作用。

谢谢,


我仍然不明白为什么它不起作用。同事建议的一个简单的解决方法:

// 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 ) {
      ....
   }    
}

The following select returns an empty result set, although it shoudn't:

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

$xml_import_id is set. And it works if I remove the where clause..

Thanks


I still don't understand why it doesn't work.. A simple workaround suggested by a 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 ) {
      ....
   }    
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一萌ing 2024-12-15 07:48:07

首先,确保在 localconf.php 中设置以下内容:

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

然后尝试

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

结果是前端查询的输出。然后可以在MySQL中执行它进行调试。

First, make sure the following is set in 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.

酒中人 2024-12-15 07:48:07

a) 确保 $xml_import_id 实际上有一个值(也在数据库中)

b) 试试这个:

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

如何处理结果?
您期望的 $xml_import_id 值是什么样的?


罗马

a) make sure $xml_import_id actually has a value (one which is in the database as well)

b) Try this:

$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?

cu
Roman

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文