PHP Laravel - 测试查询结果
PHP Laravel - Test Query Result
来自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');
这来自 invoice_detail.blade.php 我验证了查询有效。信息似乎没有进入视图或视图中的某些内容不正确。
@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
希望这对您有所帮助。我太难摆脱这种对拥有这么多代码的尖叫了。大声笑不能赢。抱歉,最初缺乏信息。我认为这可能就足够了,而且我很累。再次感谢
I'm sure it's very simple but just missing it
确实是 ;) 而您缺少的是 PHP 个标签!
<?php $result->ILINVN = 'test'; ?>
您混合使用数组和对象表示法。通常,您不能将对象作为数组访问,也不能将数组作为对象访问。
您不能使用
$result->ILINVN
和
$result['ILINVN']
其中一个不正确,但无法通过您提供的代码来判断是哪一个。
来自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');
这来自 invoice_detail.blade.php 我验证了查询有效。信息似乎没有进入视图或视图中的某些内容不正确。
@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
希望这对您有所帮助。我太难摆脱这种对拥有这么多代码的尖叫了。大声笑不能赢。抱歉,最初缺乏信息。我认为这可能就足够了,而且我很累。再次感谢
I'm sure it's very simple but just missing it
确实是 ;) 而您缺少的是 PHP 个标签!
<?php $result->ILINVN = 'test'; ?>
您混合使用数组和对象表示法。通常,您不能将对象作为数组访问,也不能将数组作为对象访问。
您不能使用
$result->ILINVN
和
$result['ILINVN']
其中一个不正确,但无法通过您提供的代码来判断是哪一个。