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

Home Posts Topics Members FAQ

Database, PDO, MySQLi, OOP, S...

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, MySQLi, SQLite, PDO... I have
noticed that PDO and MySQLi will be pervasive only in the future. One
of paid servers doesn't support MySQLi because of its platform -
CentOS.

3. I have read some notes and articles so I have stated that PDO isn't
perfect and MySQLi and MySQL are better interfaces.

4. Is SQLite3 only accessed from PDO?

5. Does procedural MySQLi use objected mechanisms?

6. I have read that OOP uses more computational power of CPU and uses
more RAM. Is it true? The main aim of this CMS is SPEED and little RAM
using. I might only use OOP for database connection like PunBB.

7. If there would be MySQL_* support, should be other function also
procedural? If a function return an object, will be it his copy or
only a reference?

Why do I need other functions? If I want to get data to an array, I
don't want to type so much code - but only call 1 function, e.g.
db_read(...)
The function would also add table's prefix to table name (as present).

Jun 4 '07 #1
2 3330
People say that structural programming isn't good for database
connection.
Is unstructured programming better then? ;) No, serious, anything you
can do with objects, you also can do with functions and "line-by-line
programming". The advantage of object orientation is mainly in its
structure. This structure will give you good chances for optimization,
if used well.
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.
When using objects, you can just use inheritance and deal with a more
"abstract" database. When using functions, you'd probably want some
database functions that you pass a parameter saying which database (and
what type; you can probably use the get_resource_ty pe function on the
connection) is used and act accordingly.
Can you give me some advices?

1. PHP4 is still used. I want to be compatible.

2. There are various methods - MySQL, MySQLi, SQLite, PDO... I have
noticed that PDO and MySQLi will be pervasive only in the future. One
of paid servers doesn't support MySQLi because of its platform -
CentOS.
If the PHP developers just drop mysql_ support, I think there will be a
huge compatibility problem. But it is an external library, so you can
probably install it on future versions. I still use it, because mysqli
does not bring me any advantages, just the disadvantage that it is not
installed on quite a number of providers.
6. I have read that OOP uses more computational power of CPU and uses
more RAM. Is it true? The main aim of this CMS is SPEED and little RAM
using. I might only use OOP for database connection like PunBB.
If you do it right, you can do a lot of optimization with objects. The
main thing here is "lazy computation": reading something in memory only
when you need it, and keeping it. This does use more memory, but saves a
lot of duplicate code (and duplicate running of code). Most procedural
or blind-panic code I have seen do not have any context to fall back on.
So it has to create any context where it is needed, bloating up a good
deal of code. But off course, it does not have to be this way.
Procedural code and object-oriented code have one thing in common: you
have to be good in programming. That said, Use the one you are familiar
with and do not be afraid to learn from other programming techniques and
languages.
7. If there would be MySQL_* support, should be other function also
procedural? If a function return an object, will be it his copy or
only a reference?
You can use the mysql_ functions from within objects (which is what I
do). What the methods of such an object return is entirely up to you. I
did have a "record" object in the past, but I switched back to using
plain arrays for the rows.
Why do I need other functions? If I want to get data to an array, I
don't want to type so much code - but only call 1 function, e.g.
db_read(...)
The function would also add table's prefix to table name (as present).
Well, that is an advantage of using an object, isn't it? you construct
the object once with a prefix, and you can forget about it. It is then
the responsibility of that object to incorporate it in anything it does
to the database.
The real world is usually somewhat more difficult. You probably also
want to write to the database. And use more than one connection,
especially if you use transactions. Just imagine what happens to an
error log table in combination with a rollback in just one connection.

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Jun 5 '07 #2
In article <46************ *********@news. xs4all.nl>, Willem Bogaerts
wrote:
People say that structural programming isn't good for database
connection.
Don't listen to people like that.

Mark

Jun 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1878
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...
5
1505
by: cover | last post by:
Is there any basic, sure fire 'if - else' script that will ensure that records entered into my form will actually be written to the database? I noticed when debugging one day that records would show up when using the print command as though they'd been entered but hadn't actually been written to the database. I'm hoping to find some sort of...
3
2839
by: Bob Bedford | last post by:
hello I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: selectdatas(array('field1','field2','fieldn'),array('table1','tablen'),array('left join,idy','inner join, idx')) then the function build the query,...
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...
9
2771
by: christopher_board | last post by:
Hi all. I am trying to write a php page which connects to a MySQL Database which is supposed to get the results from a table within a database and display the results in a table. Below is the code that I am using: <?php function connectDatabase() { $dbhost = 'localhost'; $dbuser = 'root';
2
3202
by: Michael | last post by:
Hi, I try to use mysqli object instead of standard mysql functions. Is it ok to create mysqli object within my class or schould I pass mysqli object to my object. The problem is, with code below I must call mysqli->connect() each time I call class methods. How do I create an connection for hole object, so methods can do queries without...
221
367109
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in...
3
2160
by: luke noob | last post by:
Hi i have just begun hosting my web site with a company Complia.com it has its own built in MySQL & phpmyAdmin, to create a database, im having a problem connecting to it. This is the warning i get.... Warning: mysqli::mysqli() : (HY000/2005): Unknown MySQL server host 'www.example.co.uk:2082' (1) This is my code in php..... $db_name...
0
7470
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
7405
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...
1
7428
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
7760
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
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3455
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...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1887
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.