EvilZone
Programming and Scripting => Web Oriented Coding => : pllaybuoy April 03, 2013, 08:28:31 PM
-
I am quiet familiar with php and sqls now . I've used mysql database(only) by now . Can any of you(who are used to php+sql) tell me why why some prefer mysqli over mysql ? Like in some functions .
I've used mysql_connect() and mysqli_connect both , I didn't really find a difference except that with mysqli version you don't need to use mysql_select_db('database_name'); because an extra parameter for database is allowed . Nonetheless there should be some more important reason to use mysqli functions instead of mysql ones . Also when using notepad++ it doesn't highlight mysqli_connect() and all other mysqli functions yet it does highlight mysql_connect and other functions . Apart from this function the mysql_query and mysqli_query are both nearly identical(except the arrangement of parameters) . I am a newbie , mind my ignorance please .
-regards
-
Take a look at the table near the bottom of this: http://www.php.net/manual/en/mysqli.overview.php
NP++ has horrible support for mysqli, but you'll probably get used to it.
-
If you have a look at MySQL Improved Extension Overview, it should tell you everything you need to know about the differences between the two.
The main useful features are: - an Object-oriented interface - support for prepared statements - support for multiple statements - support for transactions - enhanced debugging capabilities - embedded server support.
Source: http://stackoverflow.com/questions/548986/mysql-vs-mysqli-in-php
I use the old mysql extension on private or small projects because.. Its easier(?) and/or more familiar. However, because MySQLi is the MySQL Improved version, I use it for large, serious or otherwise important projects.
-
Use PDO instead. I don't remember the precise nick that gave me the advice on #SecurityOverride but it was well worth it to look into. I would strongly suggest using PDO for all PHP-base database access.
-
Use PDO instead. I don't remember the precise nick that gave me the advice on #SecurityOverride but it was well worth it to look into. I would strongly suggest using PDO for all PHP-base database access.
Depends on it, the mysqli(improved extension) is heavily influenced by PDO. It supports Transactions, prepared statements etc..
In short, when you are writing a new application just do not use mysql for the sake of depreciation. Also always, try to implement a sort of prepared statements for the sake of security.
If you are creating something that you are going to release PDO is a very good option because you can easily change Database drivers.
EDIT: also try to use the OOP version of MysqlI and PDO instead of a procedural approach.