Skip to content

Commit

Permalink
Use request instead of query method
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Oct 5, 2016
1 parent 3630208 commit 811a447
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions source/devapi/querydb.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
Querying database
-----------------

To query database, you can use hte ``$DB::query()`` method.
To query database, you can use the ``$DB::request()`` method and give it a full SQL query.

.. warning::

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


To make a database query that could not be done using ``$DB->request()``, to call SQL functions (``NOW()``, ``ADD_DATE()``, ...) for example, you can use the ``query()`` method:
To make a database query that could not be done using DBIterator (calling SQL functions such as ``NOW()``, ``ADD_DATE()``, ... for example), you can do:

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

0 comments on commit 811a447

Please sign in to comment.