TYPO3_DB - Database API


QUERY

  1. $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = 1;
  2.  
  3. $selectFields = '*';
  4. $fromTable = '';
  5. $whereClause = '1';
  6. $groupBy = '';
  7. $orderBy = ''; // 'field(uid,' . $orderedUidList . ')';
  8. $limit = '';
  9.  
  10. $recordList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
  11. $selectFields,
  12. $fromTable,
  13. $whereClause.$this->cObj->enableFields($fromTable),
  14. $groupBy,
  15. $orderBy,
  16. $limit,
  17. );
  18.  
  19. debug(array(
  20. 'fields' => $selectFields,
  21. 'from' => $fromTable,
  22. 'where' => $whereClause,
  23. 'enable' => $this->cObj->enableFields($fromTable),
  24. 'group' => $groupBy,
  25. 'order' => $orderBy,
  26. 'limit' => $limit,
  27. 'query' => $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery,
  28. 'recordList' => $recordList,
  29. ),'SELECT',__LINE__,__FILE__);
  30.  
  31. // direkte Weiter-Verarbeitung:
  32. foreach ((array)$recordList as $record) {
  33. $record['uid'];
  34. $translatedRecord = $GLOBALS['TSFE']->sys_page->getRecordOverlay(
  35. $fromTable,
  36. $record,
  37. $GLOBALS['TSFE']->sys_language_uid,
  38. $GLOBALS['TSFE']->config['config']['sys_language_overlay'],
  39. );
  40. }

INSERT

  1. $into_table = '';
  2. $field_values = array(
  3. 'fieldname1' => $value1,
  4. 'fieldname2' => $value2,
  5. 'fieldname3' => $value3,
  6. 'fieldname4' => $value4,
  7. 'fieldname5' => $value5,
  8. 'tstamp' => time(),
  9. 'crdate' => time(),
  10. );
  11.  
  12. $res=$GLOBALS['TYPO3_DB']->exec_INSERTquery(
  13. $into_table,
  14. $field_values,
  15. );
  16. $newUId = $GLOBALS['TYPO3_DB']->sql_insert_id();

UPDATE

  1. $into_table = '';
  2. $where_clause = '';
  3. $field_values = array(
  4. 'fieldname1' => $value1,
  5. 'fieldname2' => $value2,
  6. 'fieldname3' => $value3,
  7. 'fieldname4' => $value4,
  8. 'fieldname5' => $value5,
  9. 'tstamp' => time(),
  10. );
  11.  
  12. $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
  13. $into_table,
  14. $where_clause,
  15. $field_values,
  16. );
  17.  
  18. $cnt = $GLOBALS['TYPO3_DB']->sql_affected_rows(); // $cnt : Anzahl betroffener Datens├Ątze

DELETE

  1. $from_table = '';
  2. $where_clause = '';
  3.  
  4. $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
  5. $from_table,
  6. $where_clause,
  7. );
  8.  
  9. $cnt = $GLOBALS['TYPO3_DB']->sql_affected_rows(); // $cnt : Anzahl betroffener Datens├Ątze