Created
February 14, 2012 21:15
-
-
Save mipmip/1830511 to your computer and use it in GitHub Desktop.
TYPO3: useful db methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// create where clause for query with all enable/delete/start/stop fields | |
$wherequery = $this->cObj->enableFields('fe_users'); | |
// enable fields in exec_SELECTquery | |
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery ($fields, $table, '1=1' . $this->cObj->enableFields($table), $groupBy, $orderBy); | |
// exec_SELECTgetRows returns an array | |
$userArr = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 'uid,name,username,tx_lwhellocolleague_birthday as birthdayDate', 'fe_users','1=1'. $this->cObj->enableFields('fe_users')); | |
// The SQL which was created with above query method | |
// SELECT uid,name,username,tx_lwhellocolleague_birthday as birthdayDate FROM fe_users WHERE 1=1 AND fe_users.deleted=0 AND fe_users.disable=0 AND fe_users.starttime<=1288179060 AND (fe_users.endtime=0 OR fe_users.endtime>1288179060) | |
/* ITERATE AND READ RESULT OBJECT */ | |
// voor meerdere records | |
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dam.*','tx_dam','tx_dam_mm_cat','tx_dam_cat', | |
' AND tx_dam.deleted=0 AND tx_dam.tx_p3ga_pas3_assettype="indesign" AND tx_dam_cat'.'.uid = '.$catid, | |
$groupBy,$orderBy,$limit); | |
while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) | |
{ | |
$rows[]=$row; | |
} | |
// read just one record | |
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'uid = '.$elem_arr[1], $groupBy, $orderBy, $limit); | |
if ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) | |
{ | |
$dataToSet=$row[$elem_arr[2]]; | |
} | |
$GLOBALS['TYPO3_DB']->exec_UPDATEquery ($table, $where, $fields_values); | |
//num records | |
$count = $GLOBALS['TYPO3_DB']->sql_num_rows($res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment