Hi all

I'm encountering some problems switching to PHP 5.3.
I am now using XAMPP 1.7.2.

I had this database class extended and it worked when using PHP 5.2.9. But after the switch to 5.3 it doesn't. (Today I found out it was originally written for PHP 4 so it's pretty normal it gives errors now)

When I try to import (include/require) this class (or my database class that extends it), I get to see code from that class on the web page. (and of course, it doesn't work)

Does anyone know about a good database class for php 5.3 (preferably using mysqlnd since it's better) and a good tutorial how to install mysqlnd?

Or any other solution?

Thx in advance.
Grtz, K?!

I wouldn't suggest downloading external classes when there are two libraries already built in for mysql. One of them is oop and the other function based. The mysql class which is in oop is actually called mysqli while the other is just called mysql. Check those two links as they link to the official documentation for those libraries and should already be installed. Hope that helps.

Yes, but I'm talking about classes using those libraries.

It kind of goes like this:

  • The downloaded class uses the mysql(i) interface to provide database access and querying. It also implements exception handling.
    example functions: query("SQL Statement"), execute("SQL Statement")
  • My extension provides functions to perform specific tasks or get specific information using the functions from the downloaded class.
    example: getUser($userId) does someting like
    return parent::query(
    "SELECT *
    FROM tblUsers
    WHERE userId=".$userId
    ");
  • Then I use my extension in other classes where I need that information, so I only have to call on one function instead of using SQL Statements there

It's just an example to show what I want and need, no need to correct the code or something if something is wrong or something ;-).

Anyone?

If you don't mind the extra recourses being drained by the interface finding where to convert things then first I would suggest a google search. I tried googling and one of the first results was php mysql wrapper. Generally I prefer not to use an interface to increase speed but I suppose if you find php hard then that might be the way to go. Good luck with the google search.

Ok, thx.

I already did a google search before this post, and found some classes, but I'm not sure about using them. They're pretty much the same then the previous class I used, using mysql_...() too. I found classes for PHP 5, but I was looking for PHP 5.3 specific classes. Preferably using mysqlnd. But I'd be glad having something that just works with PHP 5.3.

You talked about draining resources. But I think keeping database access in a class has it's advantages. You can reuse the functions, so that means less code. Difficult things like exception handling are only to be coded once.
Does it really slow down performance so much to call a function from another class than to write the full code each time it is needed.
That seems weird to me, then OO programming would be kind of a stupid thing to do, right?
Or do you mean something else?

I'm don't want to argue or something, I just have my questions about it.

Grtz, K?!

Does it really slow down performance so much to call a function from another class than to write the full code each time it is needed.
That seems weird to me, then OO programming would be kind of a stupid thing to do, right?

Well the reason why OO or OOP programming is believed to be faster is because the user is giving the computer instructions in the same way that the computer thinks. And example with english is say you were given a piece of paper written in chinese and a piece of paper written in german. It would be easier for you to understand the german paper because it is closer to your language. However I am not sure if the same applies for languages where there is a compiler instead of an interpreter.

As for why it would be slower, it is because the computer is doing things that the user would normally do such as escape strings and even find where to escape the strings since an AI (Artificial Intellegence) to some degree would be needed. So the cpu effects may be minor on a small scale but if you receive a few thousand visitors a week then you would notice the difference. So generally best practice it for to use the dll's but if you messing around or aren't worried about cpu then external classes can be used for sure.

well, it's one of my first projects (non professional of course).
So keeping it easy would be nice :-).
It's only for a website with few visitors so I don't think that will be the problem.

well, it's one of my first projects (non professional of course).
So keeping it easy would be nice :-).
It's only for a website with few visitors so I don't think that will be the problem.

Didn't realise it was one of your firsts projects because you've made so many posts on daniweb. But yea. Maybe after the first year of programming you then might want to learn the best cpu techniques. Until then keeping it easy would be the main thing as some languages can be scary to learn.

I was wondering, is mysqli using mysqlnd or are those 2 different things?

Oh snap
The problem was just that in the class I downloaded "<?" was used in stead of "<?php". Kind of emberassing, but I think everyone understands that it can take a while before finding that...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.