473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Porting to mysqli from mysql

code green
1,726 Recognized Expert Top Contributor
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 2298
Atli
5,058 Recognized Expert Expert
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 Recognized Expert Top Contributor
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 Recognized Expert Expert
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
1879
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 --with-mysql=/usr/local/mysql/. However, I get the same errors when I configure without the mysql extension, just mysqli. And as the documentation says, I...
0
2128
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 mysqli options. I can get it to configure and work correctly with just the mysql but NOT the mysqli or both. Environment: Red Hat Enterprise...
0
19259
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 hell of a time with it... The following comes from phpinfo(): PHP Version: 5.1.2 mysql Client API version: 5.0.18 mysqli Client API version: 5.0.18
12
4724
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'); define('DB_PASSWORD', 'practical'); define('DB_DATABASE', 'ajax'); // connect to the database $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,...
2
2749
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 off without a hitch, but I noticed that phpMyAdmin was not able to utilize the MySQLi library (which was working with my last 5.1.x release). As I was...
13
3691
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 I am new to OOP? Thanks... Example; ======================================== <?php // webpage $newsignon = new newuser(); logon();
2
3331
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 want also to use SQLite. Can you give me some advices? 1. PHP4 is still used. I want to be compatible. 2. There are various methods - MySQL,...
11
11070
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 PDO briefly but I've not used the mysqli extension yet. I've read a bit about it though, seems good and more OOP orientated (for the most part). But...
2
3048
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 s\src/../tests_common/tableSnapshots/1_users.sql The command works fine from the mysql command line client, but when I try to run this with the mysqli query function, I...
0
7490
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7449
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.