Skip to content

Commit

Permalink
A word about Db::query()
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Oct 5, 2016
1 parent a46f0d5 commit 1aa5b00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/devapi/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Developer API
.. toctree::
:maxdepth: 2

querydb
dbiterator
16 changes: 16 additions & 0 deletions source/devapi/querydb.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Querying database
-----------------

To query database, you can use hte ``$DB::query()`` method.

.. warning::

Whether this is possible to query database directly using this method, it should be avoid when possible, and you'd better use :doc:`DBIteraor <dbiterator>` instead.


To make a database query that could not be done using ``$DB->request()``, like SQL functions call (``NOW()``, ``ADD_DATE()``, ...), you can use the ``query()`` method:

.. code-block:: php
<?php
$DB->query('SELECT id FROM glpi_users WHERE end_date > NOW()');

0 comments on commit 1aa5b00

Please sign in to comment.