gpt4 book ai didi

PHP/Zend Framework 2 - 无法在动态生成的表中显示表字段值

转载 作者:行者123 更新时间:2023-11-30 22:42:25 24 4
gpt4 key购买 nike

问题

我正在尝试使用 Zend Framework 2 和 PHP/MySQL 将字段值显示到表中。鉴于下表是动态生成的,我正在尝试获取如下所示的值。不幸的是,我只得到单元格位置的空值。

问题

我如何解决这个问题以将值填充到它们的单元格位置?

enter image description here

代码

Controller.php

   public function summaryAction()
{
return new ViewModel(array(
'actionitems' => $this->getActionItemTable()->fetchAll(),
));
}

Table.php

    public function fetchAll()
{
$select = new Select();
$select->from('actionitems', array('*'))
->join('users', 'actionitems.OwnerID = users.UserID', array('OwnerLastName' => new Expression('users.lastName'), 'OwnerFirstName' => new Expression('users.firstName')));
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}

index.phtml

        <table class="actionitemsummary">
<tr>
<th>
Team
</th>
<th>
Item #
</th>
<th>
Action Item Title
</th>
<th>
Criticality
</th>
<th>
Status
</th>
<th>
Assigned Date
</th>
<th>
Original Due Date
</th>
<th>
ECD
</th>
<th>
Closed Date
</th>
<th>
Owner
</th>
<th>
Actions
</th>
</tr>
<?php
use Application\Model\ActionItem;

/* @var $actionItem ActionItem */
?>

<?php foreach($actionitems as $actionItem): ?>
<tr>
<td class="team">
<?php echo $actionItem->team; ?>
</td>
<td class="itemnum">
<?php echo $actionItem->actionItemID; ?>
</td>
<td class="actionitemtitle">
<?php echo $actionItem->actionItemTitle; ?>
</td>
<td class="criticality">
<?php echo $actionItem->criticality; ?>
</td>
<td class="status <?php echo $actionItem->status; ?> onschedule">
<?php echo $actionItem->status; ?>
</td>
<td class="assigneddate">
<?php echo $actionItem->assignedDate; ?>
</td>
<td class="originalduedate">
<?php echo $actionItem->dueDate; ?>
</td>
<td class="ecd">
<?php echo $actionItem->ecd; ?>
</td>
<td class="closeddate">
<?php echo $actionItem->closedDate; ?>
</td>
<td class="owner">
<?php echo $actionItem->ownerID; ?>
</td>
<td class="actions">
<a href="">View</a>
</td>
</tr>
<?php endforeach; ?>
</table>

编辑:

var_dump($resultSet);

object(Zend\Db\ResultSet\ResultSet)[287]
protected 'allowedReturnTypes' =>
array (size=2)
0 => string 'arrayobject' (length=11)
1 => string 'array' (length=5)
protected 'arrayObjectPrototype' =>
object(Application\Model\ActionItem)[258]
public 'actionItemID' => null
public 'status' => null
public 'actionItemTitle' => null
public 'railName' => null
public 'team' => null
public 'criticality' => null
public 'assignedDate' => null
public 'ecd' => null
public 'dueDate' => null
public 'closedDate' => null
public 'completionDate' => null
public 'closureCriteria' => null
public 'notes' => null
public 'assignorID' => null
public 'ownerID' => null
public 'altOwnerID' => null
public 'approverID' => null
public 'rejectionJustification' => null
public 'approvalStatement' => null
public 'closureStatement' => null
public 'actionItemStatement' => null
protected 'returnType' => string 'arrayobject' (length=11)
protected 'buffer' =>
array (size=0)
empty
protected 'count' => int 15
protected 'dataSource' =>
object(Zend\Db\Adapter\Driver\Pdo\Result)[264]
protected 'statementMode' => string 'forward' (length=7)
protected 'fetchMode' => int 2
protected 'resource' =>
object(PDOStatement)[265]
public 'queryString' => string 'SELECT `actionitems`.*, users.lastName AS `OwnerLastName`, users.firstName AS `OwnerFirstName` FROM `actionitems` INNER JOIN `users` ON `actionitems`.`OwnerID` = `users`.`UserID`' (length=178)
protected 'options' => null
protected 'currentComplete' => boolean true
protected 'currentData' =>
array (size=22)
'ActionItemID' => string '1' (length=1)
'Status' => null
'Team' => null
'Criticality' => string '1 - High' (length=8)
'AssignedDate' => string '2015-06-11' (length=10)
'DueDate' => string '2015-06-02' (length=10)
'CompletionDate' => null
'ECD' => string '2015-06-07' (length=10)
'ClosedDate' => null
'ActionItemTitle' => string 'test' (length=4)
'ActionItemStatement' => string 'test' (length=4)
'AssignorID' => string '1' (length=1)
'OwnerID' => string '1' (length=1)
'AltOwnerID' => string '1' (length=1)
'ApproverID' => null
'RejectionJustification' => null
'ApprovalStatement' => null
'ClosureCriteria' => string 'test' (length=4)
'ClosureStatement' => null
'Notes' => string 'test' (length=4)
'OwnerLastName' => string 'TEST' (length=13)
'OwnerFirstName' => string 'TEST' (length=4)
protected 'position' => int 0
protected 'generatedValue' => string '0' (length=1)
protected 'rowCount' => int 15
protected 'fieldCount' => int 22
protected 'position' => int 0

以下返回所有记录如上:

for ($i = 0; $i <  $resultSet->count(COUNT_NORMAL); $i++)
{
var_dump($resultSet);
$resultSet->next();
}

最佳答案

您需要使用“foreach”从数据库中获取条目,这是 ResulSet 对象的最佳方式:

foreach($resultSet $result){
var_dump($result);
}

试一试。

关于PHP/Zend Framework 2 - 无法在动态生成的表中显示表字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30746756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com