pdostatement

PDO Prepared Statements

Is there a way to get the raw SQL string executed when calling PDOStatement::execute() on a prepared statement? For debugging purposes this would be extremely useful. ...

List of PDOStatement::bindParam data_type parameters

Is there a list describing all of the data_type parameters you can use in PDOStatement::bindParam() ? If none, what do you commonly use, and for what type of field ? According to PHP manual: *data_type* Explicit data type for the parameter using the PDO::PARAM_* constants. I know about the PDO::PARAM_INT and PDO::PARAM_STR . I've hear...

PHP PDOStatement: Fetch A Row, as the First Column as the Key of an Array

I am using PDOStatement to query the database. Whenever I get a returned row, I want it to be fetched into an array, with the $row[0] as the key, and the subsequent elements in the row as the values. I can, of course, write a combination of foreach loops and if conditionals to do the job, such as the below: private static function GetM...

PHP: How to cast object to inherited class?

I'd like to inherit PDOStatement class and use it in my website scripts. But I am frustrated how to get required object. PDO::query returns only direct PDOStatement object and looks like there are no other method to create PDOStatement object or inherited class. Initially i thought to move PDOStatement object to constructor of inherit ...