Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 27 |
MySql | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 27 |
cleanup() | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
sqlQuery($query) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
select($column, $table, array $criteria) | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 13 |
<?php | |
namespace Codeception\Util\Driver; | |
class MySql extends Db | |
{ | |
public function cleanup() { | |
$this->dbh->exec('SET FOREIGN_KEY_CHECKS=0;'); | |
$res = $this->dbh->query('show tables')->fetchAll(); | |
foreach ($res as $row) { | |
$this->dbh->exec('drop table `' . $row[0] . '`'); | |
} | |
$this->dbh->exec('SET FOREIGN_KEY_CHECKS=1;'); | |
} | |
protected function sqlQuery($query) | |
{ | |
$this->dbh->exec('SET FOREIGN_KEY_CHECKS=0;'); | |
parent::sqlQuery($query); | |
$this->dbh->exec('SET FOREIGN_KEY_CHECKS=1;'); | |
} | |
public function select($column, $table, array $criteria) { | |
$query = "select %s from `%s` where %s"; | |
$params = array(); | |
foreach ($criteria as $k => $v) { | |
if ($v === null) { | |
$params[] = "$k IS ?"; | |
} else { | |
$params[] = "$k = ?"; | |
} | |
} | |
$params = implode(' AND ', $params); | |
return sprintf($query, $column, $table, $params); | |
} | |
} |