Skip to content

Commit

Permalink
Add GROUPBY option to DBmysqlIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Walid authored and trasher committed Aug 30, 2017
1 parent b02d5f4 commit d42abbc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions source/devapi/database/dbiterator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,26 @@ Using the ``COUNT`` option:
$DB->request(['FROM' => 'glpi_computers', 'COUNT' => 'cpt']);
// => SELECT COUNT(*) AS cpt FROM `glpi_computers`
Grouping
^^^^^^^^

Using the ``GROUPBY`` option, which contains a field name or an array of field names.

.. code-block:: php
<?php
$DB->request(['FROM' => 'glpi_computers', 'GROUPBY' => 'name']);
// => SELECT * FROM `glpi_computers` GROUP BY `name`
$DB->request('glpi_computers', ['GROUPBY' => ['name', 'states_id']]);
// => SELECT * FROM `glpi_computers` GROUP BY `name`, `states_id`
Order
^^^^^

Using the ``ORDER`` option, with value a field or an array of field. Field name can also contains ASC or DESC suffix.
Using the ``ORDER`` option, with value a field or an array of fields. Field name can also contains ASC or DESC suffix.

.. code-block:: php
Expand Down Expand Up @@ -231,4 +247,3 @@ Default operator is ``=``, but other operators can be used, by giving an array c
// => SELECT * FROM `glpi_computers` WHERE `name` LIKE 'pc00%'
Know operators are ``=``, ``<``, ``<=``, ``>``, ``>=``, ``LIKE``, ``REGEXP``, ``NOT LIKE`` and ``NOT REGEX``.

0 comments on commit d42abbc

Please sign in to comment.