diff --git a/.gitignore b/.gitignore index 1363dc79..19001c5d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ www.pid *~ composer.lock .vscode +/.idea +composer.phar +.phpunit.result.cache diff --git a/src/Php7/FakePdo.php b/src/Php7/FakePdo.php index a9e2b15c..bbd72b09 100644 --- a/src/Php7/FakePdo.php +++ b/src/Php7/FakePdo.php @@ -1,16 +1,53 @@ real); } + + /** + * @param string $statement + * @return int|false + */ + public function exec($statement) + { + $statement = trim($statement); + if (strpos($statement, 'SET ')===0){ + return false; + } + + $sth = $this->prepare($statement); + if ($sth->execute()){ + return $sth->rowCount(); + } + return false; + } + + /** + * @param string $statement + * @param int $mode + * @param null $arg3 + * @param array $ctorargs + * @return FakePdoStatement + */ + public function query($statement, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) + { + $sth = $this->prepare($statement); + $sth->execute(); + return $sth; + } } diff --git a/src/Php8/FakePdo.php b/src/Php8/FakePdo.php index 668c6e8c..a7636886 100644 --- a/src/Php8/FakePdo.php +++ b/src/Php8/FakePdo.php @@ -1,16 +1,52 @@ real); } + + /** + * @param string $statement + * @return int|false + */ + public function exec($statement) + { + $statement = trim($statement); + if (str_starts_with($statement, 'SET ')){ + return false; + } + + $sth = $this->prepare($statement); + if ($sth->execute()){ + return $sth->rowCount(); + } + return false; + } + + /** + * @param string $statement + * @param int|null $mode + * @param mixed ...$fetchModeArgs + * @return FakePdoStatement + */ + public function query(string $statement, ?int $mode = PDO::ATTR_DEFAULT_FETCH_MODE, mixed ...$fetchModeArgs) + { + $sth = $this->prepare($statement); + $sth->execute(); + return $sth; + } }