[TYPO3-dev] A way to detect if table has a certain field
Tapio Markula
tapio.markula at xetpoint.fi
Thu Sep 27 19:13:41 CEST 2007
Stefan Geith kirjoitti:
> 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
almost - needs to flip values!
if(isset($avail_columns) && is_array($avail_columns))
$avail_columns=array_flip($avail_columns);
now I can test the if(isset($avail_columns['pid']) &&
isset($avail_columns['deleted'])
Thank's - I went forward.
The idea was add 'Delete all records' for records, which are not pages
and which have both pid and deleted - those are normal records.
I added configuration, what tables would get that.
So for example if you want quick delete for tt_content and tt_address
you can add that for those records - nice way to clean unwanted records
from some pages
More information about the TYPO3-dev
mailing list