• support@answerspoint.com

Different between mysql and mysqli ?

2310

Different between mysql and mysqli and its functions ? how to use its mysqli function ? What is PDO , how to use in PHP Programing 

4Answer


0

 

MySQL

[A]. MySQL is a relational database management system (or RDBMS) –meaning that it is a database management system based on the relational model. This RDMS runs as its own server and provides multi-user access to multiple databases at once. The source code of MySQL is available under the terms set forth in the GNU General Public License as well as a plethora of proprietary agreements. Members of the MySQL community have created many different branches of the RDMS –the most popular of which are Drizzle and MariaDB. As well as being the prototype of several branches, most free software projects that must have a full featured database management system (or DMS) use MySQL.

[B]. MySQL can be found in many web applications as the database component of a solution bundle (or LAMP) software stack. Its use can be seen widely in such popular web sites as Flickr, FaceBook, Wikipedia, Google, Nokia, and YouTube. Each one of these websites use MySQL for storage and the logging of user data. The code is comprised of the C and C languages and uses many different system platforms –including Linux, Mac OS X, and Microsoft Windows.

MySQLi
[A]. MySQLi Extension (or simply known as MySQL Improved or MySQLi) is a relational database driver that is used mainly in the PHP programming language. It provides an interface to the already founded MySQL databases. It is quite literally an improved version of its predecessor, MySQL, which was simply a means to manage databases over servers.

[B]. The MySQLi extension comes equipped with many benefits that compliment as well as improve those that were provided by its predecessor, MySQL. There are a few that are more prominent than others. These features that are meant to enhance the functionality of the MySQL (as well as provide an update to the database manager as a whole) are an object oriented interface, support for statements that have been previously prepared, support for a variety of statements, support for any kind of transaction that takes place, an enhanced level of debugging support, and an enhanced level of server support that is already embedded in the infrastructure of the database.

 

Summary:

1. MySQL is an RDBMS that runs as a server and provides multi-user access to multiple databases; MySQLi is an extension of MySQL.

2. MySQL does not need GUI tools in order to administer databases or manage the data therein; MySQLi builds upon the features of MySQL and include object oriented interface, support for previously prepared statements, and enhanced embedded server support

  • answered 6 years ago
  • Sunny Solu

0


There are (more than) three popular ways to use MySQL from PHP.


   A. (DEPRECATED) The mysql functions are procedural and use manual escaping.
   B.  MySQLi is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
   C. PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. It provides prepared statements, and significant flexibility in how data is returned.



 

  • answered 6 years ago
  • Sunny Solu

0

The MySQLi Extension (MySQL Improved) is a relational database driver used in the PHP scripting language to provide an interface with MySQL databases.

 

 

 

There are three main API options when considering connecting to a MySQL database server:

 

 

 

  • PHP's MySQL Extension
  • PHP's MySQLi Extension
  • PHP Data Objects (PDO)

 

 

 

The PHP code consists of a core, with optional extensions to the core functionality. PHP's MySQL-related extensions, such as the MySQLi extension, and the MySQL extension, are implemented using the PHP extension framework. An extension typically exposes an API to the PHP developer, to allow its facilities to be used programmatically. However, some extensions which use the PHP extension framework do not expose an API to the PHP developer.

 

 

 

The PDO MySQL driver extension, for example, does not expose an API to the PHP developer, but provides an interface to the PDO layer above it.

 

 

 

MySQLi is an improved version of the older PHP MySQL driver, offering various benefits.

 

 

 

  • answered 6 years ago
  • Community  wiki

0

MySQLi is improved version of MySQL. Before MySQLi we were using its old version MySQL and millions number of projects have been developed using PHP and MySQL and later PHP announce their ideas to deprecate MySQL extension in 2011. Officially MySQL has been removed from PHP 5.5

MySQLi database system is relaible for both small and large applications.

MySQLi is open source relational database management system which is used on web.

MySQL must not be used in new development anymore.

Old extension does not support Prepared Statements and improved version of MySQL (MySQLi) and PDO that support Prepared Statements are object oriented.

For security reasons, you must use Prepared Statements. Its very important for your web application security.

By using Prepared Statements, you can protect your application from SQL injection.

MySQLi support for multiple statements and enhance debugging capabilities.

For MySQLi installation, click here : http://php.net/manual/en/mysqli.installation.php

You can connect your application to database by two ways :

  • Connection with the object oriented way
  • Connection with the procedural way

Connection with the object oriented way

I always recommend to open database connection by using object oriented way because it is very faster, secure and efficient.


 
  1. $db = new mysqli('host', 'user', 'password', 'database');
  2.  
  3. if($db->connect_errno > 0){
  4. die('Error : ('. $db->connect_errno .') '. $db->connect_error);
  5. }

Connection with the procedural way

It is helpful for those user who want to switch to MySQLi from old MySQL because it is much similar to MySQL.


 
  1. $db = mysqli_connect('host','user','password','database');
  2. // check connection
  3. if (mysqli_connect_errno()) {
  4. trigger_error('Database connection failed: ' . mysqli_connect_error(), E_USER_ERROR);
  5. }
  • answered 6 years ago
  • Community  wiki

Your Answer

    Facebook Share        
       
  • asked 6 years ago
  • viewed 2310 times
  • active 6 years ago

Best Rated Questions