Author Topic: mysql or mysqli ? your preference ?  (Read 1215 times)

0 Members and 2 Guests are viewing this topic.

Offline pllaybuoy

  • Peasant
  • *
  • Posts: 70
  • Cookies: -3
    • View Profile
mysql or mysqli ? your preference ?
« on: 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
"Monsters are real , ghosts are real too . They live inside us and sometimes they win"

Offline Fur

  • Knight
  • **
  • Posts: 216
  • Cookies: 34
    • View Profile
Re: mysql or mysqli ? your preference ?
« Reply #1 on: April 03, 2013, 10:24:56 pm »
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.

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: mysql or mysqli ? your preference ?
« Reply #2 on: April 04, 2013, 12:24:26 am »
Quote
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.
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: mysql or mysqli ? your preference ?
« Reply #3 on: April 04, 2013, 01:16:03 am »
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.
-Xires

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: mysql or mysqli ? your preference ?
« Reply #4 on: April 05, 2013, 09:23:08 am »
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.
« Last Edit: April 05, 2013, 09:24:55 am by Factionwars »
~Factionwars