Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.6. Section 4 - Database

About this section

Functions related to databases queries.

Those functions are available in any context, but they will need the AI class to be instantiated most of the time.

db_table2text

Export a database table to text format.

This function returns a database table contents as a formatted text variable. By default, it generates a tabulated text file.

SPECIAL NOTE: This function can be called without the API class instantiated.

Parameters

Parameter:

Default value:

Description:

$table

The table to export.

$fieldList
'*'

The list of fields to select from the table.

$whereClause
''

Optional WHERE clauses put in the end of the query, if none, supply blank string.

$groupBy
''

Optional GROUP BY field(s), if none, supply blank string.

$orderBy
''

Optional ORDER BY field(s), if none, supply blank string.

$limit
''

Optional LIMIT value ([begin,]max), if none, supply blank string.

$sepField
9

The ASCII separator character for each field.

$sepRow
10

The ASCII separator character for each row.

$directOut
0

Output the generated file directly as a text file.

$directOutCharset
'iso-8859-1'

The charset for the output file.

Return

The formatted database table contents.

See also
  1. div_output

db_table2xml

Export a database table to XML format.

This function returns a database table contents as an XML object.

SPECIAL NOTE: This function can be called without the API class instantiated.

Parameters

Parameter:

Default value:

Description:

$table

The table to export.

$fieldList
'*'

The list of fields to select from the table.

$whereClause
''

Optional WHERE clauses put in the end of the query, if none, supply blank string.

$groupBy
''

Optional GROUP BY field(s), if none, supply blank string.

$orderBy
''

Optional ORDER BY field(s), if none, supply blank string.

$limit
''

Optional LIMIT value ([begin,]max), if none, supply blank string.

$uppercase
0

Use uppercase for XML tags.

$xmlDeclaration
1

Insert XML declaration.

$xmlVersion
'1.0'

The XML version.

$xmlEncoding
'iso-8859-1'

The XML encoding.

$directOut
1

Output the generated file directly as an XML file.

$ns
false

The XML namespace.

$nsPrefix
'ns'

The prefix used in the XML to link elements to the namespace.

Return

The database table contents as XML nodes.

See also
  1. div_output

Examples

Here's the kind of output you will get:

1:

2:

3:

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

14:

15:

16:

17:

18:

19:

20:

<?xml version="1.0" encoding="iso-8859-1"?> 
<!--
- Typo3 XML Export
- 
- Generation Time: Thu, 25 Nov 2004 23:00:00 +0100
- 
- Host: localhost
- Database: typo3_db
- Table: fe_users
-->
<typo3_db>
<fe_users>
<uid>1</uid>
<username>admin</username>
</fe_users>
<fe_users>
<uid>2</uid>
<username>macmade</username>
</fe_users>
<typo3_db>

This example has been generated with the following command:

1:

2:

// Export fe_users

$this->api->table2xml('fe_users','uid,username');