[eluser]ale21ale[/eluser]
Hello Guys!
this is amazing ! , very thanks stensi. First, sorry for my english.
I have problems with the join of tables.
My data model :
Code:
class Costumer extends DataMapper {
$table = 'costumers';
var $has_many = array('invoice','receipt');
}
class Invioce extends DataMapper {
$table = 'invoices';
var $has_one = array('costumer');
var $validation = array(
array(
'field' => 'date',
'label' => 'Invoice date',
'rules' => array('valid_date','required')
),
array(
'field' => 'total',
'label' => 'Invoice total',
'rules' => array('required')
)
);
}
class Receipt extends DataMapper {
$table = 'receipts';
var $has_one = array('costumer');
var $validation = array(
array(
'field' => 'date',
'label' => 'Receipts date',
'rules' => array('valid_date','required')
),
array(
'field' => 'total',
'label' => 'Receipts total',
'rules' => array('required')
)
);
}
When i use my costumer model , i have 2 records set or objects set =):
$costumer->invoice and $costumer->receipts , but i need make a report like this :
from costumer id : 1
date (from receipts or invoices) invoice sum receipt sum
2008-03-20 200 u$s
2008-02-22 150 u$s
2008-02-23 150 u$s
2008-02-23 100 u$s
when using native sql query i created a table with union and ordered by date. Received a set of records and printed without any problems. How can I do this using datamapper?
Very thanks for the work. Congraturations =)
Ale.
Web development