[TYPO3-dev] A way to detect if table has a certain field

Stefan Geith typo3dev2007 at geithware.de
Thu Sep 27 17:05:49 CEST 2007


Hi Tapio,

Tapio Markula schrieb:

> ...
>> DESCRIBE myTable myField
>> If the field is found, there'll be a result row.
> which MySQL supports that?
> 
> what Typo3 call I could use?
> I mean something like
> $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(*)',$table,'pid='.$id.' 
> AND deleted=0','', '', '');

Maybe you need something like this:

$query = 'SHOW COLUMNS FROM '.$this->mainTable.' ;';
$res = $GLOBALS['TYPO3_DB']->sql_query($query);
if ($res) {
	while ($defRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
	avail_columns[] = $defRow['Field'];
}

					
-

Stefan




More information about the TYPO3-dev mailing list