Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I migrate my site from mysql to mysqli? [duplicate]

Tags:

php

mysqli

Is there anything I have to do on the database end or is it just the php that changes? Can I just substitute mysqli functions for mysql functions? Anything else I should know?

like image 763
dac Avatar asked Jan 04 '11 21:01

dac


People also ask

How do I switch from MySQL to MySQLi?

with mysql, you have to use the mysql_select_db once connected, to indicate on which database you want to do your queries. mysqli, on the other side, allows you to specify that database name as the fourth parameter to mysqli_connect . Still, there is also a mysqli_select_db function that you can use, if you prefer.

Can I use both MySQL and MySQLi?

It is possible to include both MySQL and MySQLi when connecting to a single database, but it is incredibly delicate and with large amounts of data being passed through it can get very messy and hard to control. it is best to use MySQLi in general in my opinion because it is much more secure and up to date.

Is MySQLi better than MySQL?

Basically, MySQL is the old database driver, and MySQLi is the Improved driver. The "i" stands for "improved" so it is MySQL improved. MySQLi can be done procedural and object-oriented whereas MySQL can only be used procedurally. Mysqli also supports prepared statements which protect from SQL Injection.

Which MySQL command can be used as replacement for the Mysql_select_db ()?

Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alternatives to this function include: mysqli_select_db()


2 Answers

I advise you to read through this. A lot of helpful information for what you want to do, plus a tool to help. See: Converting to MySQLi.

It's just the PHP that changes.

like image 70
BasBenIk Avatar answered Sep 20 '22 08:09

BasBenIk


Everything I know about it says that the only changes you will have to make will be in the PHP. With that said be careful not all functions have the same name between the two so be careful changing from mysql_* to mysqli_*.

The site php.net will be your best friend.

like image 45
PseudoNinja Avatar answered Sep 19 '22 08:09

PseudoNinja