Search Results

Search found 1 results on 1 pages for 'tgun926'.

Page 1/1 | 1 

  • How do check if PDO object is connected properly inside a different class?

    - by tgun926
    I want to fetch some information from my mysql database in a class, so I'm passing in the PDO object into a __construct function, and working from there. However, what's an elegant way of checking to see if the PDO object was correctly created, and that the connection is open when the Table class is instantiated? class Table{ public function __construct(PDO $db, $week){ try{ $query = $db -> query ("SELECT * FROM `table1` where `day` = 'monday'"); } catch(PDOExeption $e){ echo 'error: '. $e->getMessage(); //die(); } } } I don't think this code does what I want.

    Read the article

1