私はこのクエリ文字列を持っています...
select i.invoiceid, i.date, i.total, i.total - (select ifnull(sum(p.amount), 0) from payment p where p.invoice = i.invoiceid) as remainingbalance
from invoice i inner join client c
on i.client = c.clientid
where i.isdeleted = 0 and i.client = 1
union
select p.paymentid, p.date, p.invoice, p.amount from payment p inner join invoice i
on i.invoiceid = p.invoice
inner join paymenttype
on paymenttype.paymenttypeid = p.paymenttypeid
inner join client c
on c.clientid = i.client
where c.clientid = 1
and i.isdeleted = 0
order by date
これを試すと…
<?php
echo $clientArrayInvoice[1]['paymentid'];
?>
$clientArrayInvoice で print_r を実行しても結果が得られない
Array ( [0] => Array ( [invoiceid] => 1 [date] => 2012-04-12 [total] => 602.29 [remainingbalance] => 300.96 ) [1] => Array ( [invoiceid] => 1 [date] => 2012-04-27 [total] => 1.00 [remainingbalance] => 301.33 ) )
なぜこれを行うのかは理解していますが、返された結果のpaymentid
代わりに列を表示するにはどうすればよいですか。何がで何invoiceid
が であるかを判断できるので、これが理にかなっていることを願っています。paymentid
invoiceid