0

Ok So I have seen a few things.. But is there anything that goes into depth more but sort of squared away...

From what it looks like if you develop something in mysqli - it will be faster

mysql pdo - works with a bunch of other databases..

I found this but -Click Here
Cons pros?

Any info explaining anymore? - API supports Multiple Statements ? most? Is there a list somewhere?

5
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by veedeoo
2

@xbat

From what it looks like if you develop something in mysqli - it will be faster

I like MYSQLI more because it's easier to manage.

Regarding about PDO it's hard to grasp but you're right about it's more flexible.

0

Yeah @LastMitch is right, MYSQLI is easier to manage.

I read somewhere that PDO means that you do not have to worry about SQL injection I don't know how true this is though

0

If you use MySQLi correctly with bound parameters, injection gets very difficult. I prefer PDO because I can switch to a different server easily. Base your decision on what you need to make. For example, with PDO you can use the fetch object method that uses YOUR objects and injects the data from the record.

2

For example, with PDO you can use the fetch object method that uses YOUR objects and injects the data from the record.

I guess you are talking about this:

if ($pdoStatement) {
// perhaps you want to check if there are any rows available
if ($pdoStatement->rowCount() == 0) {
echo '<p>No records found.</p>';
}
else {
while ($recordObj = $pdoStatement->fetchObject()) {
echo $recordObj->mycolumn;
}
}
$pdoStatement->closeCursor();
}

http://www.daniweb.com/web-development/php/code/435142/using-phppdo-with-error-checking

I did test it out 2 months ago. It is very hard to grasp. I have to practice more on PDO.

Edited by LastMitch: grammer

0

thanks everyone for the input.. I guess the biggest thing is.. At least I have a much better point of view and this does surely help shadow some light on it this.

1

I love both of them, depending on application requirements. There is a neglectable performance differences between the two. MySQLI is somewhat faster than the PDO... however like what Pritaeas already mentioned, PDO can function and work in different environment.

One specific reason out of all other reasons, why I would also prefer PDO is that it can take an instance of a class and use it as the parameter on its query, this is called PDO fetch class . This functionality is perfect for applications requiring the implementation of a templating system like the smarty, dwoo, twig, tinybutstrong, and others. Although, it can be use in tinybutstrong environment, I prefer to use the built-in tinybutstrong database interface.

For example, say we have a class called rockStars ( Why some geeks adore rock stars and rock stars wishes to be a geek at some point of their lives?? wow! I can trade places at any time)..

  class RockStars{

  public function get_RockStars($name,$band,$cd){

  return array($name,$band,$cd);

  }
  }

 $thisPDO = $db->prepare("SELECT name, band,cd FROM rockstars");

 $thisPDO->execute();

 ## grab the output array and send it to the template engine or just loop over it

 ## for the template
 $smarty->assign('rockStars', $thisPDO->fetchAll(PDO::FETCH_CLASS, "RockStars"));

 ## you can loop through the result below as you wish
 $this_PDO_result = $thisPDO->fetchAll(PDO::FETCH_CLASS, "RockStars");

That's all I can say on this subject matter... performance wise? MYSQLI got a meniscule upper hand, but PDO supports named_parameters and supports many different database.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.