Havent even looked into mysqli tbh yet. But mysql is something I am used to.
Printable View
Whats the difference between mysql_ and mysqli?
Its recommended to use mysqli for anything past 4.1.x (forgot the exact version). Its also more stable and more secure, as you can used prepared statements with mysqli.
Security is always #1 so there is no question about which one you should use.
Yes ron you are right.
But, When you have come use to a language..Its kind of hard to put it down and then learn something new.
I would like to 'master' you could say - mysql, then move onto mysqli. As goes with all the web languages, Not ALL its not like I want YQL but anyways the scripts above were mysql not mysqli. Also, alot of people have mysql on there webserver and they can't change there code to accustom mysqli.
mysqli = MySQL Improved
*php.internals: deprecating ext/mysqlCode:mysqli mysql
==========================================================================
Development Status Active Maintenance only
Lifecycle Active Long Term Deprecation Announced*
Recommended Yes No
OOP API Yes No
Asynchronous Queries Yes No
Server-Side Prep. Statements Yes No
Stored Procedures Yes No
Multiple Statements Yes No
Transactions Yes No
MySQL 5.1+ functionality Yes No
now, i finally got something to do again ...
I recently decided to move from mysqli to PDO.
I had a 170 line class (including comments) that handled automating and simplifying (named) parametrized queries with mysqli, but decided that I could do all that and more with PDO.
I recoded the class with PDO in 49 lines (including comments), and it does everything that the mysqli class does, plus I set it up to return resultsets in a much more organized and workable manner. (Do note that the resultset is a small separate class I created which PDO loads data into.)
After doing a bit more research into execution speed differences between the two libraries, I was somewhat surprised to find out that most of the functions have a very minimal execution speed difference.
MySQLi extension is organized the same way as the mysql extension. It's not a learning curve, it's just one letter and a bunch of extra features- mainly prepared statements and parameterized queries.
ex:
The database is still MySQL and is 100% compatible with the query language you're used to, but the API for talking to the MySQL database is improved and slightly altered to accommodate for new features in MySQL databases. You'd only be a fool not to switch to a better API such as PDO or MySQLi.PHP Code:$query = mysqli_query('SELECT * FROM messages LIMIT 30'); // get messages
var_dump(mysqli_fetch_assoc($query)); //first row (first message)
The reason PHP left the old mysql_ extension and created a new mysqli_ extension rather than simply updating the original library is beyond me- but now a bunch of new developers such as yourself are learning old, deprecated things and are confused about the two extensions for the same database. I understand your confusion, but you must understand you are confused.
So and why you should change to mysqli, when you already have a project with mysql started?
Why you should change to mysqli, when you don't use these many extra functions of mysqli?
so far
Yannici
well i think it wont hurt to keep your application like it is for now, mysql will still be a part of preset plugins for years. however, if you are going to use your application for many years i recommend to update it to PDO or MySQLi.
although, your next project shouldnt be with the MySQL ext for sure.
im currently in almost the same situation, i got a class with many many mysql/mssql queries. im thinking on rebuilding the class into PDO, but im lazy to do that now and test all over again. *sign*, sometimes its rly better to go with the time, i mean, i tell the ppl mssql ext is outdated at php 5.3+, they should use sqlsrv ext instead, how can i keep my application using mysql ext in that case? >.>
well ill find the time and go for PDO ...
Well that questions were general and not specially about my application(s), but you're right.
It's really better to get with the time. And I think every PHP-Developer with skills can change his
project from mysql to mysqli pretty fast, when he have a mysql class ;)
It's always better to be updated than outdated :D
so far
Yannici
True. That's why I were asking about the session things. Nothing new about the sessions didn't came up. I wanted it to be ONE function only working same way as it does with raw script and } } ending tags, but I think it's not possible unless you change it to revert and you call functions INSIDE of issets.
Here are some classes I wrote for my php framework using mySQL, mysqli, and pdo. Including a result.obj class. I use MySQLi the most just out of pref.
https://github.com/Makarovich/Blowfi...asses/database
Sent from my DROID RAZR using Tapatalk 2