diff --git a/src/Codeception/Module/Db.php b/src/Codeception/Module/Db.php index e48ff7156f..2e372a8f44 100644 --- a/src/Codeception/Module/Db.php +++ b/src/Codeception/Module/Db.php @@ -534,6 +534,16 @@ protected function countInDatabase($table, array $criteria = []) return (int) $this->proceedSeeInDatabase($table, 'count(*)', $criteria); } + /** + * Fetches all values from the column in database. + * Provide table name, desired column and criteria. + * + * @param string $table + * @param string $column + * @param array $criteria + * + * @return array + */ protected function proceedSeeInDatabase($table, $column, $criteria) { $query = $this->driver->select($column, $table, $criteria); @@ -573,6 +583,21 @@ public function grabColumnFromDatabase($table, $column, array $criteria = []) return $sth->fetchAll(\PDO::FETCH_COLUMN, 0); } + /** + * Fetches all values from the column in database. + * Provide table name, desired column and criteria. + * + * ``` php + * grabFromDatabase('users', 'email', array('name' => 'RebOOter')); + * ``` + * + * @param string $table + * @param string $column + * @param array $criteria + * + * @return array + */ public function grabFromDatabase($table, $column, $criteria = []) { return $this->proceedSeeInDatabase($table, $column, $criteria);