Skip to content
Advertisement

Tag: pdo

PDO and MySQL ‘between’

I’m trying to get PDO to work with a MySQL ‘between’. Below is my code: What gets returned is an array with ‘0’ or ‘NULL’ for values. When I hard code the end date, it acts as if start_date is set to -1, retuning me all rows before the end_date. So, what am I doing wrong here? Answer Don’t wrap

Using pdo in php with stored procedure

I have a simple stored procedure in MySQL database: When calling this procedure in mysql-workbench it returns the data I put in: Now when I call it from PHP using pdo I get an error: Here is my php code: Answer You need to use bindValue instead of bindParam. When you use bindParam, it binds the variable provided to the

Select on empty table but still get column names

I want to do a SELECT on an empty table, but i still want to get a single record back with all the column names. I know there are other ways to get the column names from a table, but i want to know if it’s possible with some sort of SELECT query. I know this one works when i

PDO get the last ID inserted

I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing. I know that I have to use this statement: That statement works with a query like this: But if I want to get the ID using this statement: I get this error: What am I doing wrong?

PDO were rows affected during execute statement

I have found many ways to use the exec statement for PDO, but I’m not sure it helps me. My understanding is that I have to use the execute() function for prepared statements. I am updating a row with data from user input, so I would like to use a prepared statement instead of the query() call. My code is

Advertisement