2014-04-06 2 views
0
select '0000-00-00' as date, 'Opening Balance' as narration, (SELECT debit FROM `account_sub_journal` where id=1)as debit, (SELECT credit FROM `account_sub_journal` where id=1)as credit, '0' as transaction_entry_id,'0' as account_sub_journal_id UNION SELECT * FROM `ledgertransactions` where account_sub_journal_id = 1 and `date` BETWEEN '2014-04-01' and '2014-04-10' 

저는 현재 모델에서 정적 함수로 이것을합니다. laravel이 객체Laravel Raw 쿼리 페이지 매김; 웅변적인 객체에 대한 원시 쿼리

public static function ledgerbook_to($account_id,$date){ 
     $book = DB::select(DB::raw("SELECT '0000-00-00' AS DATE, 'Opening Balance' AS narration, (SELECT debit FROM `account_sub_journal` WHERE id =1) AS debit, (SELECT credit FROM `account_sub_journal` WHERE id = :account_id) AS credit, '0' AS transaction_entry_id, '0' AS account_sub_journal_id UNION SELECT * FROM `ledgertransactions` WHERE account_sub_journal_id =:account_id_t and `date` <= :date_to "), array(
    'account_id' => $account_id,'account_id_t' => $account_id,'date_to' => $date)); 
     return $book; 
    } 

나는 적어도 웅변에 쿼리 아래 해결이 경우 조합 할 수없는 말했다 이후이 페이지를 매기는 없습니다.

SELECT '0000-00-00' AS DATE, 'Opening Balance' AS narration, (SELECT debit FROM `account_sub_journal` WHERE id =1) AS debit, (SELECT credit FROM `account_sub_journal` WHERE id =1) AS credit, '0' AS transaction_entry_id, '0' AS account_sub_journal_id 

귀하의 지원에 감사드립니다

답변

3
수동으로 같은 것을 사용하여 페이지 매김 링크를 생성 할 수 있습니다

:

$pagination = Paginator::make($book, count($book), 5); 

그런 다음이 같은 것을 사용할 수 있습니다 :

echo $pagination->links(); 

또는 (Blade) this :

{{ $pagination->links() }} 

수동으로 페이지 번호를 만드는 방법에 대해 자세히 알아 보려면 the documentation을 확인하십시오.

+0

완벽하게 DB에서 작동하지 않습니다 :: select 메서드 – Metra

+0

어떻게? @Metra,'array'를'$ books'로 전달해야합니다. –