Subject RE: [firebird-php] What approach are people using? ORM for FB
Author Alan McDonald
> I have a rather large PHP5 application that I'm building, using a MVC
> approach with Firebird on the back-end for everything. Its
> incredibly fast,
> and this is a dynamite technology combination!
> I'm building classes that represent my data access to Firebird. All of my
> access to the Firebird data is done through Stored Procedures, so I have
> been able to abstract the tables in such a way that represents
> the 'business
> objects' as best I can to map to PHP classes.
> But as I get through this application, I'm starting to find the need to
> create forms that work with multiple classes, or at least forms that work
> with a main class by that the class has a one to many relationship with
> other classes. I'm probably not saying this correctly, as this
> is more of a
> relational model way of expressing it, but here's a typical
> example of what
> I'm finding.
> I have a 'Job' (Work Order) that is stored in a single table in Firebird,
> and is represented as a single class called 'Job' in PHP. A job can have
> one or many workers assigned to it. There is a class for
> 'Worker' that is a
> single table in Firebird and a single class in PHP. There is a separate
> table in Firebird representing the relationship between the Job and the
> Workers assigned to it. This resolves a many to many relationship between
> Jobs & Workers.
> On my form in HTML, I have the job and all of its properties
> showing. But I
> need a table within the form that shows all the Workers assigned to it.
> When I look at the class of Job, I have singular properties (ie. Scheduled
> date, Priority, etc.). That's all fine. But how do I represent the
> collection of workers who are assigned to it? For me, its easy in a
> relational world because I just create a join table and that's
> it. But how
> is this represented in PHP as classes?
> I'm sure this is pretty rudimentary stuff, but I'm curious as to how other
> PHP-Firebird developers deal with this sort of thing. Are there any good
> reference books on how to 'think' in regards to Object-Relational
> Mapping so
> that I can follow some 'best practices' for this sort of thing
> and minimize
> the amount of management code I have to write to pull all of this
> together?
> Thanks in advance for any advice.
> Regards,
> Myles

part of you workorder class in PHP is an object called JobWorkers. It's an
array of type Workers. So you can have nil or many objects of workers in
every Workorders class. You Workers class has a parameter which, when set,
pupolates the workers class with workers of a particular type, i.e. of a
particular workorder. Is that something like what you need?