语法错误或访问冲突Laravel 4

时间:2015-02-20 04:50:48

标签: php mysql laravel phpmyadmin

我在我的控制器中使用了这个查询

DB::insert(DB::raw( "CREATE TEMPORARY TABLE temp1 ENGINE=MEMORY AS (SELECT a.account AS Account, a.name AS Account_Name, 0 AS Amount FROM coa a);") );

    DB::insert("INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.ar) AS Amount FROM coa a, jurnal b WHERE a.name=b.ar_coa);
        INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.terima_cicilan) AS Amount FROM coa a, jurnal b WHERE a.name=b.terima_cicilan_coa);
        INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.bunga) AS Amount FROM coa a, jurnal b WHERE a.name=b.bunga_coa);
        INSERT INTO temp1 (SELECT b.account AS Account, b.name AS Account_Name, SUM(((a.nilai_pinjaman*a.biaya_admin)/100)) AS Amount FROM ar a, coa b WHERE b.name='PENDAPATAN ADMINISTRASI');");

    $report = DB::select(DB::raw("SELECT Account,Account_Name,SUM(Amount) AS Amount FROM temp1 GROUP BY Account;"));

在phpmyadmin中查询显示

CREATE TEMPORARY TABLE temp1 ENGINE=MEMORY 
AS (SELECT a.account AS Account, a.name AS Account_Name, 0 AS Amount FROM coa a);
INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.ar) AS Amount FROM coa a, jurnal b WHERE a.name=b.ar_coa);
INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.terima_cicilan) AS Amount FROM coa a, jurnal b WHERE a.name=b.terima_cicilan_coa);
INSERT INTO temp1 (SELECT a.account AS Account, a.name AS Account_Name, SUM(b.bunga) AS Amount FROM coa a, jurnal b WHERE a.name=b.bunga_coa);
INSERT INTO temp1 (SELECT b.account AS Account, b.name AS Account_Name, SUM(((a.nilai_pinjaman*a.biaya_admin)/100)) AS Amount FROM ar a, coa b WHERE b.name='PENDAPATAN ADMINISTRASI');
SELECT Account,Account_Name,SUM(Amount) AS Amount FROM temp1 GROUP BY Account;
像这样

Image

我的查询或代码有什么问题?仅在laravel中执行该查询

0 个答案:

没有答案