Showing posts with label pdo. Show all posts
Showing posts with label pdo. Show all posts

Tuesday, June 5, 2012

PHP PDO: Can I bind an array to an IN() condition?


I'm curious to know if it's possible to bind an array of values to a placeholder using PDO. The use case here is attempting to pass an array of values for use with an IN() condition. I'm not very good at explaining, so here's some psuedocode to demonstrate... I'd like to be able to do something like this:

Friday, May 25, 2012

mysqli or PDO - what are the pros and cons?


In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.

Tuesday, May 15, 2012

Wednesday, May 9, 2012

How do I know if a Prepared Statement is being Cached?


I have been reusing the same variable $stmt in my PHP script to write prepared statements:

Friday, May 4, 2012

Use of PDO in classes


I have a few classes that perform some MySQL queries and prepared statements. However, I am lost in how to incorporate my PDO object within those classes. For example, I want to do something like this:

Thursday, April 12, 2012

How do I create a PDO parameterized query with a LIKE statement in PHP?


Here's my attempt at it:




$query = $database->prepare('SELECT * FROM table WHERE column LIKE "?%"');
$query->execute(array('value'));
while ($results = $query->fetch())
{
echo $results['column'];
}

Friday, February 10, 2012

Converting MySQL to PDO


I've been advised a couple of times on here to start changing my code to PDO and I've finally got round to doing it. My problem is that I'm having incredible difficulty with converting my existing login script. For the last few lines of the code below (after the line $result = $query->fetchAll(); ) I haven't been able to find any resources online that could help me re-write it:

Friday, January 13, 2012

PDO_OCI: could not find driver


Today my problem is connected with PDO, OCI8 and PDO_OCI. But from the beginning.