[TYPO3-dev] A way to detect if table has a certain field
Tapio Markula
tapio.markula at xetpoint.fi
Thu Sep 27 20:49:15 CEST 2007
Georg Ringer kirjoitti:
> Tapio Markula wrote:
>> $row=$GLOBALS['TYPO3_DB']->sql_fetch_row($row);
>
> use $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($row);
>
> georg
In fact I must flip in this case too
$query = 'SHOW COLUMNS FROM '.$table.' ;';
$res = $GLOBALS['TYPO3_DB']->sql_query($query);
if ($res) {
while ($defRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$avail_columns[] = $defRow['Field'];
}
}
if(isset($avail_columns) && is_array($avail_columns))
$avail_columns=array_flip($avail_columns);
but anyway at that way was possible to get name of the field.
But just as key name.
In one solution I needed the actual values - and used indexed arrays.
I needed to comment, what field each index means.
$this->pageRecord=$GLOBALS['TYPO3_DB']->exec_SELECTquery('doktype,content_from_pid,title,uid,shortcut,shortcut_mode,mount_pid,mount_pid_ol,url,urltype,module','pages','uid='.$this->id.'','',
'', '');
$this->pageRecord=$GLOBALS['TYPO3_DB']->sql_fetch_row($this->pageRecord);
$this->doktype=$this->pageRecord[0];
It would be aeasier if I could get named keys instead.
More information about the TYPO3-dev
mailing list