Skip to content

Commit

Permalink
[Db] fix grabFromDatabase description in docs (#5717)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitrichius authored and Naktibalda committed Oct 14, 2019
1 parent 131eefb commit ffef68b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
16 changes: 13 additions & 3 deletions docs/modules/Db.md
Expand Up @@ -271,18 +271,28 @@ $mails = $I->grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter'

### grabFromDatabase

Fetches all values from the column in database.
Fetches a single column value from a database.
Provide table name, desired column and criteria.

``` php
<?php
$mails = $I->grabFromDatabase('users', 'email', array('name' => 'RebOOter'));
$mail = $I->grabFromDatabase('users', 'email', array('name' => 'Davert'));
```
Comparison expressions can be used as well:

``` php
<?php
$post = $I->grabFromDatabase('posts', ['num_comments >=' => 100]);
$user = $I->grabFromDatabase('users', ['email like' => 'miles%']);
```

Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.

* `param string` $table
* `param string` $column
* `param array` $criteria


* `return` mixed Returns a single column value or false


### grabNumRecords
Expand Down
17 changes: 13 additions & 4 deletions src/Codeception/Module/Db.php
Expand Up @@ -883,19 +883,28 @@ public function grabColumnFromDatabase($table, $column, array $criteria = [])
}

/**
* Fetches all values from the column in database.
* Fetches a single column value from a database.
* Provide table name, desired column and criteria.
*
* ``` php
* <?php
* $mails = $I->grabFromDatabase('users', 'email', array('name' => 'RebOOter'));
* $mail = $I->grabFromDatabase('users', 'email', array('name' => 'Davert'));
* ```
* Comparison expressions can be used as well:
*
* ```php
* <?php
* $post = $I->grabFromDatabase('posts', ['num_comments >=' => 100]);
* $user = $I->grabFromDatabase('users', ['email like' => 'miles%']);
* ```
*
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
*
* @param string $table
* @param string $column
* @param array $criteria
* @param array $criteria
*
* @return mixed
* @return mixed Returns a single column value or false
*/
public function grabFromDatabase($table, $column, $criteria = [])
{
Expand Down

0 comments on commit ffef68b

Please sign in to comment.