tables
Scotte Meredith
spomacguy at gmail.com
Sat Mar 18 21:52:35 UTC 2023
So here's a possible scenario off the top of my head:
oMyOrderObject
-- tOrderHeader
-- tOrderRow
-- tCustomer
-- tStockItem
You instantiate oMyOrderObject as ioMyOrderObject. Inside you have a row for the order header, list of the order rows, row for customer, list for stock items.
Your window fields point to those rows and headers.
Have methods:
ioMyOrderObject.$getCustomer
ioMyOrderOjbect.$getStockItem
ioMyOrderOjbect.$saveOrder
$verifyOrder makes sure you have the customer record, there is enough stock available for all the order rows and returns something if they don't all match up
$saveOrder copies the customer key into Order header, decrements the stock items. Then saves order header and gets the key, stuffs that key into each of the order rows and saves them, then saves the stock items to update the available stock. Do that all in a single transaction.
The tOrderHeader might have a method $getByPK that does the SQL to pull up a record from a primary key. Or others to do other searches, so you could do that SQL within the table class as a separate set of methods.
So to quote Tolkien:
"One object to rule them all, one object to find them, one object to call the tables classes and in the database bind them. In Postgres, where the data lies."
> On Mar 18, 2023, at 12:51 PM, Daniel Sananes <daniel.s at kopparbergs.se> wrote:
>
> Hi Scotte
>
> Would the object class have one $definefromsqlclass for the order-header and one for the orderrows?
> And "helper table classes" for client.
> In this case there would be 3 different $definefromsqlclass all assigned inside the object.
> Then with returning-clause one would get the PK for the different datatables?
>
> Is there correct OO to perform code inside a table to get values that do not belong to the table-instance?
> I am almost not understanding my own question here.
>
> Another question, are there situations where you would not use the table-instances but perform sql outside the table?
> Do I understand this question? Maybe...
>
> Regards
> Daniel
Scotte Meredith
spomacguy at gmail.com
509/998-0991
More information about the omnisdev-en
mailing list