0

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;
    }
3
Contributors
3
Replies
14
Views
3 Years
Discussion Span
Last Post by pritaeas
0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.