-1
The following error in my code is occurring:
Warning : PDO :: query(): SQLSTATE [HY000]: General error: the mode must be an integer in C: xampp htdocs joel_php curso_hcode DAO
sql.php on line 34Fatal error : Error not detected: Call to a member function execute () on bool in C: xampp htdocs joel_php curso_hcode
DAO sql.php: 35 Stack tracking: #0 C: xampp htdocs
joel_php curso_hcode DAO indexx.php (7): Sql-> select ('SELECT * FROM t ...') #1 {main} released in C: xampp htdocs joel_php
curso_hcode DAO sql.php on line 35
class Sql extends PDO{
private $conn;
public function __construct(){
$this->conn = new PDO("mysql:host=localhost;dbname=dbphp7","root","");
echo "funcione";
}
private function setParams($statment,$paraneters = array()){
foreach($paraneters as $key =>$value){
$this->setParam($statment,$key,$value);
}
}
private function setParam($statment,$key,$value){
$statment->bindParam(":{$key}",$value);
}
public function execQuery($rawQuery,$params = array()){
$stmt = $this->conn->prepare($rawQuery);
$this->setParams($stmt,$params);
$stmt->execute();
return $stmt;
}
public function select($rawQuery,$params = array()):array{
$stmt = $this->conn->query($rawQuery,$params);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
?>´´´
Please observe the guidelines in the original question for editing and possible reopening: https://answall.com/questions/526537/aviso-pdo-query-sqlstate-hy000#comment955094_526537
– Bacco