473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Porting to mysqli from mysql

code green
1,726 Expert 1GB
I am still using the mysql extension rather than the mysqli.
Moving to mysqli would be realively simple in my case because all mysql_ procedural calls are wrapped in a class MySqlDB().
As are mssql_ procedural calls and both inherit from an abstract class that handles common functionallity baseDB().

So to switch I need to edit a few lines in the MySqlDB class.
At least I think it is that simple.
But as I already have a class inheriting from a base class what is the best way to implement the mysqli extension?

By inheriting mysqli from MySqlDB class?
Instantiating mysqli from MySqlDB class?
Or competely abandon MySqlDB and re-write hundreds of scripts?
Jun 17 '09 #1
3 2290
Atli
5,058 Expert 4TB
Hi.

I would just replace the calls to the mysql extensions with calls to the mysqli extension. In your case it should be as simple as modifying a few lines in your MySqlDB class, right?

This is the point of encapsulation and abstraction in OOP; to be able to modify the inner workings of a class without affecting the code already using it.

Unless you want to have both versions: MySQLDB and MySQLiDB, or something.
Jun 17 '09 #2
code green
1,726 Expert 1GB
I have only glanced at mysqli tutorials, but don't you have to create a mysqli object to use the extension?
I have also noticed complaints of a performance loss from switching.
Can't corroborate this but idly googling for performance pulls a few articles
Jun 17 '09 #3
Atli
5,058 Expert 4TB
You can use mysqli in two ways, using the mysqli object itself, or the mysql-like functions. The functions were created to ease the transition from the old mysql extension, I believe.

Simply adding a "i" to your old mysql function call should work for most of them.
Just check out the manual entries. They always list a procedural function and a OOP method for each of them.

As to the performance loss, I don't know. I've never tested it myself, but the few articles I've seen about this didn't really worry me.
Anyways, the real power of the Improved MySQL extension is in the prepared statements.
Jun 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: yzzzzz | last post by:
Hi, I am compiling PHP 5.0.2 myself with MySQL support. I did a ./configure --with-mysqli=/usr/local/mysql/bin/mysql_config (see end of post for complete configure) Note: I also have...
0
by: Roy Shaw | last post by:
When configuring PHP5 (5.0.3) to use the mysqli libraries I get a "No such file or directory" from the configure script. My goal is to get PHP5 running with mysql 4.1.09 with both the mysql and...
0
by: IamtheEvster | last post by:
Hi All, I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a...
12
by: davids58 | last post by:
trying to figure out how to use a mysql database with PHP. I ran the following code: <?php // defines database connection data define('DB_HOST', 'localhost'); define('DB_USER', 'ajaxuser');...
2
by: Curtis | last post by:
Hello everyone: Recently, I decided to upgrade to PHP 5.2.0. I have C:\php5 in the Windows XP PATH, so upgrading is quite painless; just unzip new release, and restart Apache! Usually it goes...
13
by: Schmidty | last post by:
If you do a page reload with $_SERVER will your program lose a mysqli connection upon the reload of the page? Would this code work? I need to know how to carry over a connection between methods as...
2
by: webcm123 | last post by:
People say that structural programming isn't good for database connection. I code fast-running structural oriented CMS and I don't know what I should do. I use mysql connection using mysql_*. I...
11
by: macca | last post by:
Hi, What should I be using for general MySQL database access? I've been using the traditional mysql extension for ages, but I'm trying to update my style to a more OOP paradigm. I've used...
2
by: Taras_96 | last post by:
Hi everyone, I'm trying to run a number of commands stored within a sql file from within php using mysqli::query. The syntax I'm using is: source C:\data\projects\forum...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.