escaping column name with PDO

Yes, PDO does not have a builtin function for delimiting identifiers like table names and column names. The PDO::quote() function is only for string literals and date literals. For what it’s worth, when I worked on Zend Framework, I implemented a quoteIdentifier() function. You’re right that SELECT * fetches all columns, likely using more memory … Read more

Insert value list does not match column list: 1136 Column count doesn’t match value count

Your database table has 35 columns id_logged, patient_id, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eightteen, nineteen, twenty, twone, twtwo, twthree, twfour, twfive, twsix, twseven, tweight, twnine, thirty, thone, thtwo, date_now Where as the values you are passing are 34 columns VALUES (:id_logged, :patient_id, :one, … Read more

PDO Unbuffered queries

The issue is that mysql only allows for one outstanding cursor at a given time. By using the fetch() method and not consuming all the pending data, you are leaving a cursor open. The recommended approach is to consume all the data using the fetchAll() method. An alternative is to use the closeCursor() method. If … Read more

PDO bindParam into one statement?

Example 2 on the execute page is what you want: $sth->execute(array(‘:calories’ => $calories, ‘:colour’ => $colour)); You may want to look at the other examples too. With question mark parameters, it would be: $q = $dbc -> prepare(“INSERT INTO accounts (username, email, password) VALUES (?, ?, ?)”); $q->execute(array($_POST[‘username’], $_POST[’email’], $_POST[‘password’])); If those are the only … Read more

PHP namespace PDO not found

You should be using correct namespaces for the objects in your methods, either “use” them or prefix them with the root namespace; <?php //… namespace etc… use \PDO; self::$connection = new PDO(“mysql:host=$host;dbname=$base”, $user, $pass); or simply; self::$connection = new \PDO(“mysql:host=$host;dbname=$base”, $user, $pass);

PHP: mysql v mysqli v pdo [closed]

The design of the mysql_query function is such that you’ve got to be careful to escape each and every bit of data you’re injecting into it, and if you miss even one your entire application can be destroyed by an automatic SQL vulnerability exploit tool. Both mysqli and PDO support placeholders which are required to … Read more