Skip to content

Commit

Permalink
[TASK] Remove old TYPO3_DB based db API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lolli42 committed Sep 9, 2016
1 parent e3207f9 commit 0df338a
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions Documentation/ApiOverview/MainClasses/HighPriorityFunctions/Index.rst
Expand Up @@ -604,120 +604,6 @@ real documentation is found in the source scripts (and the
\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-new');


.. _high-priority-functions-database-connection:

\\TYPO3\\CMS\\Core\\Database\\DatabaseConnection
""""""""""""""""""""""""""""""""""""""""""""""""

This class is always accessed via its global instance :code:`$GLOBALS['TYPO3_DB']`.

.. t3-field-list-table::
:header-rows: 1

- :Function,30: Function
:Comments,70: Comments


- :Function:
:code:`exec_INSERTquery`

:code:`exec_UPDATEquery`

:code:`exec_DELETEquery`

:code:`exec_SELECTquery`
:Comments:
**Database Access API**

To be compatible with the DataBase Abstraction Layer (DBAL) you should always
use the global object :code:`$GLOBALS['TYPO3_DB']` for database access. The class
:code:`\TYPO3\CMS\Dbal\Database\DatabaseConnection` contains a list of MySQL wrapper functions (:code:`sql()`,
:code:`sql_fetch_assoc()`, etc.) which you can use almost out of the box
as a start. This way your extension will be able to run properly on other
supported DBMSes (i.e. MS SQL Server, Oracle and PostgreSQL).

.. note::
When writing code for the TYPO3 backend, you should rely on :ref:`TCEmain <using-tcemain>`
whenever possible.

**Inserting a record:**

Just fill an array with "fieldname => value" pairs and pass it to
:code:`exec_INSERTquery()` along with the table name in which it should be
inserted::

$insertFields = array(
'md5hash' => $md5,
'tstamp' => time(),
'type' => 2,
'params' => $inUrl
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery(
'cache_md5params',
$insertFields
);

**Updating a record:**

Create an array of "fieldname => value" pairs before calling
:code:`exec_UPDATEquery()`. The function call is almost like inserting, but
you need to add a WHERE clause to target the update to the record you
want to update. It is the second argument you set to a value like
"uid=???". ::

$fields_values = array(
'title' => $data['sys_todos'][$key]['title'],
'deadline' => $data['sys_todos'][$key]['deadline'],
'description' => $data['sys_todos'][$key]['description'],
'tstamp' => time()
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'sys_todos',
'uid=' . intval($key),
$fields_values
);

**Deleting a record:**

Call :code:`exec_DELETEquery()` with the tablename *and* the WHERE clause
selecting the record to delete::

$GLOBALS['TYPO3_DB']->exec_DELETEquery(
'sys_todos',
'uid=' . intval($key)
);

**Selecting a record:**

Call :code:`exec_SELECTquery()` with at least the first three arguments
(field list to select, table name and WHERE clause). The return value
is a result pointer (or object) which should be passed to
:code:`sql_fetch_assoc()` in a loop in order to traverse the result rows. ::

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
$theTable,
$theField . '="' .
$GLOBALS['TYPO3_DB']->quoteStr($theValue, $theTable) . '"' .
$this->deleteClause($theTable) . ' ' .
$whereClause,
$groupBy,
$orderBy,
$limit
);
$rows = array();
while(($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
$rows[] = $row;
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
if (count($rows)) return $rows;

.. tip::
There are many more select methods in :code:`\TYPO3\CMS\Dbal\Database\DatabaseConnection`, look at
its API for details.



.. _high-priority-functions-beuser:

\\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication
Expand Down

0 comments on commit 0df338a

Please sign in to comment.