Jump to content

include functions in a class!


webbhelp

Recommended Posts

Hi!

 

I have a class with many functions/methods. I want to split this into different files so I can easily edit and add functions.

I want every functions to be able to call eachother and with that I mean, they have to be for example in same document.

 

My question is: I can't have a class and include functions like this:

 

class DB
{

include('select_functions.php'); //Only includes function's no class
include('insert_functions.php'); //Only includes function's no class
include('delete_functions.php'); //Only includes function's no class

function test()
{

}

}

 

The includes will output fatal errors...

 

How can I solve this so I can have all functions in different files but still use ONE object to call them!

 

Thanks!

Link to comment
Share on other sites

You're going about this the wrong way.  Classes can't be split up like you want them to be.  If you feel your class is flawed due to its length, you should look into refactoring it into other, smaller classes.

 

In any event, you're also trying to reinvent the wheel when PHP already has several OOP database options available to use - MySQLi and PDO.  Look into them to see if they'd fit your needs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.