I have a database that I've build using PDO, and I am building some database tests using phpunit. However, I need to test some cases involved with pdo exec(), that returns a false or an int. What I want to know is: In which case pdo exec() will return false?
For example: I have this method that creates my database table. When my pdo exec() will be false?
public function createTable(): \PDO
{
try {
$createTable = "
CREATE TABLE IF NOT EXISTS Transactions(
idTransaction int NOT NULL PRIMARY KEY AUTO_INCREMENT,
description varchar(255) NOT NULL,
price float NOT NULL,
category varchar(45) NOT NULL,
date varchar(10) NOT NULL,
type TINYINT NOT NULL);";
$this->pdo->exec($createTable);
return $this->pdo;
} catch (\PDOException $PDOException) {
throw new \PDOException($PDOException->getMessage());
}
}