简体   繁体   中英

TYPO3: exec_SELECTquery with where clause

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

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.

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

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