Please consider my "execute" method of my db class. When I pass it a bad sql, it does not thow the PDOException, just returns $return === false and does not do anything in the db. What am I missing?

    public function execute($sql){
      if (!$this->connection){
        try{
            $conn = new pdo(self::$dbName
                            ,self::$user
                            ,self::$password);
        }
        catch  (PDOException $e) {
            $c = "Error in connecting <br/>";
            $c .= $e->getmessage() . "<br/>";
            p0110error::terminal($c);
        }
       $this->connection = $conn;   
      }
      try{
        $return = $this->connection -> exec($sql);
      }
      catch (PDOException $e){
        $c = "Error in sql <br/>";
        $c .= $sql . "<br/>";
        $c .= $e->getmessage() . "<br/>";
        p0110error::terminal($c);
      }
      if ($return === false) {
        $c = "Error in sql <br/>";
        $c .= $sql . "<br/>";
        $c .= "... returned false <br/>";
        p0110error::terminal($c);
      }
      return $return;
    }

if ($return === false) {

Has to be:

if ($return == false) {

What you are saying in your first argument is that: $return is the type of false Attempt to use just == and post what happens. I believe this is the case for here.

Thanks.... But the problem is not in the $result, but rather that the pdoException does not fire.

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.