Hello,
I have been working for some time now on a PHP OOP database abstraction
layer. Yes I know there are others out there which are maturing but I like
reinventing this wheel.
The task I have at hand is that I want to specify 'has a' and 'has many'
relationships in an array for each class and use these to automagically
create the accessor methods and perhaps mutator methods as well.
Can anyone point me to a good reference on creating class methods on the fly
in PHP?
I have spent the afternoon studying how Perl's lovely Class::DBI handles
this but I can't get my head around how I would create these methods based
on my array values in PHP.
Any pointers and links greatly appreciated!
jg 6 2005
"jerrygarci uh" <de*****@no.spa m.nolaflash.com > wrote in message
news:yoOSd.4956 $SF.1881@lakere ad08... Hello,
I have been working for some time now on a PHP OOP database abstraction layer. Yes I know there are others out there which are maturing but I
like reinventing this wheel.
The task I have at hand is that I want to specify 'has a' and 'has many' relationships in an array for each class and use these to automagically create the accessor methods and perhaps mutator methods as well.
Can anyone point me to a good reference on creating class methods on the
fly in PHP?
I have spent the afternoon studying how Perl's lovely Class::DBI handles this but I can't get my head around how I would create these methods based on my array values in PHP.
Any pointers and links greatly appreciated!
jg
It's called eval().
On Tue, 22 Feb 2005 16:30:54 -0600, "jerrygarci uh"
<de*****@no.spa m.nolaflash.com > wrote: I have been working for some time now on a PHP OOP database abstraction layer. Yes I know there are others out there which are maturing but I like reinventing this wheel.
Don't we all. I'm about to write my 2nd or 3rd database abstraction
layer.
The task I have at hand is that I want to specify 'has a' and 'has many' relationship s in an array for each class and use these to automagically create the accessor methods and perhaps mutator methods as well.
Well if you are using PHP5 than you have lots of options available.
Thankfully my project is in PHP5 and get to use those options. If
you're using PHP4 than your only option is to use eval().
Can anyone point me to a good reference on creating class methods on the fly in PHP?
The only problem with using eval() is that you cannot add methods to a
class this way. You can, however, build entire classes with eval()
which might be the way to go.
: On Tue, 22 Feb 2005 16:30:54 -0600, "jerrygarci uh"
: <de*****@no.spa m.nolaflash.com > wrote:
:
: >The task I have at hand is that I want to specify 'has a' and 'has many'
: >relationship s in an array for each class and use these to automagically
: >create the accessor methods and perhaps mutator methods as well.
You might be happier doing all this in Perl instead...
Matt,
Isn't that always true?
jg
"Matt Mitchell" <m_************ *************** *@metalsponge.n et> wrote in
message news:H_******** ***********@fe1 .news.blueyonde r.co.uk... : On Tue, 22 Feb 2005 16:30:54 -0600, "jerrygarci uh" : <de*****@no.spa m.nolaflash.com > wrote: : : >The task I have at hand is that I want to specify 'has a' and 'has many' : >relationship s in an array for each class and use these to automagically : >create the accessor methods and perhaps mutator methods as well.
You might be happier doing all this in Perl instead...
Ladies and gentlemen we have a winner!! This is totally what I should do,
extend the child class to include the new methods!!
Thank you!
jg
"Wayne" <no*@here.com > wrote in message
news:lf******** *************** *********@4ax.c om... On Tue, 22 Feb 2005 16:30:54 -0600, "jerrygarci uh" <de*****@no.spa m.nolaflash.com > wrote:
I have been working for some time now on a PHP OOP database abstraction layer. Yes I know there are others out there which are maturing but I like reinventing this wheel.
Don't we all. I'm about to write my 2nd or 3rd database abstraction layer.
The task I have at hand is that I want to specify 'has a' and 'has many' relationshi ps in an array for each class and use these to automagically create the accessor methods and perhaps mutator methods as well.
Well if you are using PHP5 than you have lots of options available. Thankfully my project is in PHP5 and get to use those options. If you're using PHP4 than your only option is to use eval().
Can anyone point me to a good reference on creating class methods on the fly in PHP?
The only problem with using eval() is that you cannot add methods to a class this way. You can, however, build entire classes with eval() which might be the way to go.
On Tue, 22 Feb 2005 16:30:54 -0600, "jerrygarci uh"
<de*****@no.spa m.nolaflash.com > wrote: I have been working for some time now on a PHP OOP database abstraction layer. Yes I know there are others out there which are maturing but I like reinventing this wheel.
The task I have at hand is that I want to specify 'has a' and 'has many' relationship s in an array for each class and use these to automagically create the accessor methods and perhaps mutator methods as well.
Can anyone point me to a good reference on creating class methods on the fly in PHP?
I have spent the afternoon studying how Perl's lovely Class::DBI handles this but I can't get my head around how I would create these methods based on my array values in PHP.
Any pointers and links greatly appreciated!
If you're using PHP5 you could use: http://www.php.net/manual/en/languag...verloading.php
... which can act quite similarly to Perl's AUTOLOAD method to pretend to be
dynamically created methods.
--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard |
last post by:
Hi all,
I am looking for some help on understanding the overhead associated with
object creation in Java.
I am writing an application where I have written a class to encapsulate some
text data.
The class is contains these private variables:
|
by: mirandacascade |
last post by:
When I look at how classes are set up in other languages (e.g. C++), I
often observe the following patterns:
1) for each data member, the class will have an accessor member
function (a Get<whatever> function)
2) for each data member, the class will have a mutator member function
(a Set<whatver> function)
3) data members are never referenced directly; they are always
referenced with the accessor and mutator functions
My questions are:
|
by: Todd A. Anderson |
last post by:
I've inherited two "C++" code bases that I have to tie together
and both of them make frequest use of public member variables
in spite of all the information saying this limits flexibility. Well,
their lack of foresight has bit me of course! I'd like to start off
by converting all their public member variable accesses to the
use of accessor methods. Then, I can reimplement selected
accessor methods to provide the necessary glue between...
|
by: Generic Usenet Account |
last post by:
A lot has been said in this newsgroup regarding the "evil" set/get
accessor methods. Arthur Riel, (of Vanguard Training), in his class,
"Heuristis for O-O Analysis & Design", says that there is almost never
an excuse for accessor methods. Personally, I do not go that far. I
do feel that they serve a useful purpose (albeit in a limited manner).
Personally I prefer dropping the "set" and "get" prefixes from the
method names altogether. ...
|
by: LuCk |
last post by:
Can someone explain what these really are for example:
----------------------------------------------------------
void SetFrameRate(int iFrameRate) { m_iFrameDelay = 1000 / iFrameRate; };
----------------------------------------------------------
I know what functions are and i know what void is and stuff but i dont get
the whole `Accessor Methods` term i guess.
| |
by: Jason Shohet |
last post by:
I have a class with protected variables and some accessor methods, , get,
set ...
Maybe I have a brain blockage today but I'm thinking, why not just make
those variables public.
After all, someone can do just as great harm by misusing a set { }
accessor method as just doing myObj.lastname = "Big Bird"; which he
could do in a second class, if the variable is public on the first class.
IOTW, what does keeping with the protected /...
|
by: Tenacious |
last post by:
I have been programming using C# for over a year now and I still wonder
what is the importance of using accessor methods when the property is
read-write. It seems easier to just make it a public property of the
class, but I have read in more than one book that this is a bad
practice. The books did not mention the reason why this is a bad
practice. Can anybody give me some insight on this?
|
by: AAJ |
last post by:
Hi all
I would like to have a class that can set/return values of different
datatype via a single accessor, i.e. overload the accessor
i.e. something like
DateTime m_DateValue;
string m_StringValue;
|
by: Tim Sprout |
last post by:
Why is it considerd best practice to use Properties rather than Get and Set
accessor methods?
-Tim Sprout
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |