On 12 Nov 2012, at 17:09, Mehboob Alam wrote:
> Is there any equivalent to "ActiveRecord" in Active4D; or how to go about
> implementing this.
Mehboob -
The nearest I can think of in Active4D is the "Poor Man's Class" (see docs).
This could let you hide all kinds of logic in an Active4D psuedo-class
structure and do stuff like Client.find(10)
The equivalent notation in Active4D would be: $client->set("ID";10)
That would then fire a method encapsulated in the "Poor Man's Class" ( $client)
which would do the queries, load the data etc. But you would have to architect
the inner workings yourself (for example, decide whether you used local data
structures or 4D current selections / records to cache the data).
What you can't do is multiply-instantiate the object (at least without some
very tedious groundwork), i.e.
$myClient1:=Client.find(10)
$myClient2:=Client.find(20)
. . . which I guess is why Aparajita called it the "Poor Man's Class".
Despite that, in all my life I've almost never come across an instance where I
had to multiply instantiate anything in high level business application
development. I always thought that was one of the things that makes low level
programming very different from high level.
Just my thoughts on the face of it - it's an interesting question because
you've hit on one of the single big contrasts between the 4D environment and
other ones. I'm sure AF can supply a more definitive perspective since he works
across them all.
Peter
_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/