Customer table
///////////////////////////////////////////////////////////
| id[PR] | name | email |
| 10 | fabio | fab@fab.com |
| 11 | james | james@james.com |
Order table
//////////////////////////////////////////////////////////////////
| order_id[PR] | ship_to[FK] | bill_to[FK] | customer[FK] | product, total, etc
| 251 | 3 | 2 | 10 | . . .
Ship to table
//////////////////////////////////////////////////////////////////////
| customer[FK] | ship_to[PR] | label | address | city, state, zip, etc
| 10 | 3 | office | 123 main st | . . .
| 10 | 1 | home | 85 some place st | . . .
Bill to table
///////////////////////////////////////////////////////////////////////////
| customer[FK] | bill_to[PR] | label | account | billing details
| 10 | 2 | visa | AES_CRYPT(temp storage) | . . .
| 10 | 1 | mc | AES_CRYPT(temp storage) | . . .
Ok so each customer can have multi-ship to addresses and multi-payment methods on file in their account. When they place an order the order table stores the cart and session information.
I need to generate invoices how do I structure my query so that when i lookup the order table i can see the row of ship to table and the row of bill to table instead of the id of the row in the associated table.
Now mind you i don’t expect anyone to write my code but if you can please give me some links to read up on that would be great or an example would be awesome. Please note im building on codeigniter so im using the MVC pattern.
? – Should all of these lookups be structured in 1 model function or should they be spread over several functions in the model?
return $this->db->get('order_table')->result();
#this would return all the orders in the order table .
in my view i would foreach these results and make the order-id a link to more details/ invoice page. How do i pass the values from the row to the model query to generate the proper details/invoice page?
E.g. – So if you click on order 251, you will see a details page with an invoice that will say
- customer id 10
- name: fabio
- email: fab@fab.com
- ship to: office, 123 main st…
- bill to: visa, acct#, etc…
1 Answer