TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-31-2009, 05:16 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default DB wrapper for framework

Hi!

I got really interested in frameworks, especially the MVC pattern, so I followed a tutorial on how to create an own framework. Works great! Only one thing, or well, actually I have a couple of questions, but let's just take first thing's first.

The tutorial showed how to create a Database class, but that was only for MySQL. I'm only using MySQL so for me it won't be a problem, but I would love to learn how to create some kind of wrapper instead. So that it gets the desired DB engine(ofcourse you have to write seperate classes for each engine) based on what the user writes in the configuration file.

Right now it's used like this:
my bootstrap file:
PHP Code:
require_once LIBPATH 'Database' EXT
then inside the default Controller(the one which all the rests will extend):
PHP Code:
$this->db =& load_class('Database'); 
Is there any way I can .. when I load the Database class, it checks the configuration for what db engine, include the specified engine class, instanciate it, and return it?

Basicly, I want the $this->db to become an instance of DBmysql if that's specified, so that the Database class only works like a.. wrapper or gateway?

Or will I have to do this in another way for it to work?

EDIT: I already have functions to check if a config item is set. I only need help with the actual Database wrapper and how to accomplish so $this->db becomes instance of the specified engine
__________________
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comment on my database wrapper. bdm Advanced PHP Programming 8 05-24-2013 12:43 PM
Gravatar Wrapper Class Wildhoney Script Giveaway 31 01-29-2013 12:43 PM
Ping.FM Wrapper Class Daniel Script Giveaway 0 06-21-2008 05:55 PM


All times are GMT. The time now is 12:26 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design