dongliyu3278 2015-01-06 19:45
浏览 56
已采纳

PHP Laravel - 测试查询结果

From routes.php

Route::post('/invoices/detail/', function()
    {

    $db = new \PDO("odbc:DRIVER={AS400 Driver}; SYSTEM=mysystem.test.com;", "myid", 
"mypasswd");

     $query  = "SELECT ILINVN, ILLINE, ILDATE, ILPROD, IDESC, ILQTY, (ILNET * ILQTY) AS 
AMOUNT FROM mydb LEFT OUTER JOIN mydb ON ILPROD = IPROD WHERE ILINVN = 
:invoice_number";


    //query system
    $statement = $db->prepare($query);

    $statement->bindValue(':invoice_number', Session::get('invoice_number'),  
  PDO::PARAM_STR);

    if($statement->execute() !== false)
    {

        //save system query results
        $results = $statement->fetchAll(PDO::FETCH_ASSOC);
    }
    else
    {

        $results = array();

    }

    return View::make('invoice_detail')->with('results', $results);

})->before('auth');

This is from invoice_detail.blade.php I verified the query works. It appears the information is not making it to the view or something in the view is incorrect.

@extends('layouts.master')

@section('content')

@if(isset($results))

 <div class="col-md-12">

    <div class="pull-left">

        <div>

        </div>

    </div>

     <div class="pull-right">

    </div>

 </div>

<div class="col-md-12">

     <h4>Tracking</h4>

    <div class="table-responsive">

         <table class="table table-bordered table-condensed table-hover table-striped">

            <tr>

                <td><p><strong>Invoice Number</strong></p></td>
                <td><p><strong>Line #</strong></p></td>
                <td><p><strong>Invoice Date</strong></p></td>
                <td><p><strong>Item</strong></p></td>
                <td><p><strong>Description</strong></p></td>
                <td><p><strong>Qty Shipped</strong></p></td>
                <td><p><strong>Ext. Amt.</strong></p></td>

            </tr>

            @foreach($results as $result)

            <tr>
                <td><p>{{ $result['ILINVN'] }}</p></td>
                <td><p>{{ $result['ILLINE'] }}</p></td>
                <td><p>{{ $result['ILDATE'] }}</p></td>
                <td><p>{{ $result['ILPROD'] }}</p></td>
                <td><p>{{ $result['IDESC'] }}</p></td>
                <td><p>{{ $result['ILQTY'] }}</p></td>
                <td><p>{{ $result['AMOUNT'] }}</p></td>             
            </tr>

            @endforeach

        </table>

    </div>

 </div>
 @endif
 @stop

Hope this helps. Too me a bit to get rid of this screaming about having so much code. lol Can't win. Sorry the lack of information initially. I thought it might be enough plus I was tired. Thanks again

  • 写回答

2条回答 默认 最新

  • doufang1954 2015-01-06 19:53
    关注

    I'm sure it's very simple but just missing it

    Indeed it is ;) And what you're missing are PHP tags!

    <?php $result->ILINVN = 'test'; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了