Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix grabFromDatabase description in docs #5717

Merged
merged 1 commit into from Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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