MySQLi
Moderator: General Moderators
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
MySQLi
I came across this in the PHP manual...however other than a new set of defined functions im not grasping the advantage differences...What is this Mysqli....why would i want to use it rather than MySQL...
what other advantages are there to this MySQLi over MySQL
Kendall
what other advantages are there to this MySQLi over MySQL
Kendall
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
MySQLi is available as objects and can perform multiple queries in a single call. It, by default, has a more updated interface than the MySQL extension (the last time I checked.) However that specific "problem" can be overcome with updating the MySQL libraries.
There are probably a few other advantages, but I can't think of them right now.
There are probably a few other advantages, but I can't think of them right now.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
HMMm...i was just lloking at that...its seems they chose to revise the mysql functionality of PHP...I have also had scenarios where i wanted to do multiple statements and i have encountered alot of time s where i want to us MYSQL VARIABLES something that i fine is a bit "tedious" to code in PHP...
i hope these version offer more flexibility with these such aspects...
has anyone ever successfully used the MySQLi over the MySQl...what about performance and stuff...anything new?
i hope these version offer more flexibility with these such aspects...
has anyone ever successfully used the MySQLi over the MySQl...what about performance and stuff...anything new?
I have been using PDO for some time now and found it superior to the mysql functions. Supposedly this is the direction PHP will be going and it makes sense overall to go with a unified class structure like this. MySQLi is kind of like a step between mysql and pdo as it adds in some of the functionality in a procedural format.
Pros of PDO
- Generic: you can change the underlying database and only have to update any minor sql differences if any (if you went from mysql to mssql you would have to change every function using the regular mysql functions). Moving sites from mysql to postgres or mssql is cake, all you have to do is change the database url.
- Secure: if you use prepared statements it will properly escape strings using the underlying database library, no need to call mysql_real_escape_string() on every var. If you move to a different database it will escape it properly for that database. This has saved me a ton of copy and pasting and sanity checks. All you have to do is remember to make everything a prepared statement and you are golden.
- Extendable: You can extend PDO to throw custom exceptions, add in new methods, change which PDOobjects it returns etc.
- A lot faster when doing multiple queries using prepared statements especially if the underlying database driver natively supports prepared queries.
Cons
- The underlying driver implementation for mssql needs serious hot hot developer love.
- Slower that mysql on single record queries, this has not been noticeable to me but I have read it can be amplified under a lot of load
- PHP development recently has been getting weird, for instance as of today the version of PDO in PECL is older and incompatible with compiled install of php 5.2 from source. Major distributions have yet to create a package at this point. This has been a nightmare for us. Also phpize is broken currently on a lot of dists and php developers have not been in a rush to fix it. For this reason along we are considering dropping PDO and possibly PHP altogether if it does not improve.
- PDO has had some really weird bugs pop up for us. Very hard to trace bugs including it throwing exceptions that disappear and cause the apache thread to die. These can happen if you bind variables wrong. This has been mostly alleviated in the latest version right before php 5.2.
Pros of PDO
- Generic: you can change the underlying database and only have to update any minor sql differences if any (if you went from mysql to mssql you would have to change every function using the regular mysql functions). Moving sites from mysql to postgres or mssql is cake, all you have to do is change the database url.
- Secure: if you use prepared statements it will properly escape strings using the underlying database library, no need to call mysql_real_escape_string() on every var. If you move to a different database it will escape it properly for that database. This has saved me a ton of copy and pasting and sanity checks. All you have to do is remember to make everything a prepared statement and you are golden.
- Extendable: You can extend PDO to throw custom exceptions, add in new methods, change which PDOobjects it returns etc.
- A lot faster when doing multiple queries using prepared statements especially if the underlying database driver natively supports prepared queries.
Cons
- The underlying driver implementation for mssql needs serious hot hot developer love.
- Slower that mysql on single record queries, this has not been noticeable to me but I have read it can be amplified under a lot of load
- PHP development recently has been getting weird, for instance as of today the version of PDO in PECL is older and incompatible with compiled install of php 5.2 from source. Major distributions have yet to create a package at this point. This has been a nightmare for us. Also phpize is broken currently on a lot of dists and php developers have not been in a rush to fix it. For this reason along we are considering dropping PDO and possibly PHP altogether if it does not improve.
- PDO has had some really weird bugs pop up for us. Very hard to trace bugs including it throwing exceptions that disappear and cause the apache thread to die. These can happen if you bind variables wrong. This has been mostly alleviated in the latest version right before php 5.2.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
This is why I stay away from the bleeding edge.- PHP development recently has been getting weird, for instance as of today the version of PDO in PECL is older and incompatible with compiled install of php 5.2 from source. Major distributions have yet to create a package at this point. This has been a nightmare for us. Also phpize is broken currently on a lot of dists and php developers have not been in a rush to fix it. For this reason along we are considering dropping PDO and possibly PHP altogether if it does not improve.