Doctrine orm 在我的视图文件中显示DB记录时,Zend2/doctrine分页的异常行为
我正在使用DoctorinePaginator()提供的学说 但我遇到了非常奇怪的行为 这是我使用SQL Developer运行SQL的屏幕截图()(此处运行oracle 11g)。这基本上就是信条所运行的。正如你在记录100中看到的,一个姓“艾伦”的人。当我试图在视图文件中显示记录时,就会出现这种奇怪的行为 第二个屏幕截图()将$recordsPerPage设置为100(请参见下面的控制器代码)。图像顶部会告诉您使用的SQL($queryBuilder->getDql())。从图中可以看到,页面中的最后一个人是姓“Azamov”的人。根据我在SQLDeveloper中运行的SQL,记录100中的人应该是姓“Allen”的人 您还可以在“Azamov”下面看到数字100。这是通过在我的查看页面中初始化名为$tempCounter的变量,然后使用+++$tempCounter将其递增来计算的。(最后查看代码) 在图像顶部附近看到的290号来自$adapter->count()(也可以在下面的控制器代码中找到) 第三个屏幕截图()将$recordPerPage设置为200。同样,“Azamov”是最后一个人 在我看来,不知何故,显示的记录并没有遵循我在SQL中设置的顺序 有什么不对劲吗?谢谢Doctrine orm 在我的视图文件中显示DB记录时,Zend2/doctrine分页的异常行为,doctrine-orm,zend-framework2,Doctrine Orm,Zend Framework2,我正在使用DoctorinePaginator()提供的学说 但我遇到了非常奇怪的行为 这是我使用SQL Developer运行SQL的屏幕截图()(此处运行oracle 11g)。这基本上就是信条所运行的。正如你在记录100中看到的,一个姓“艾伦”的人。当我试图在视图文件中显示记录时,就会出现这种奇怪的行为 第二个屏幕截图()将$recordsPerPage设置为100(请参见下面的控制器代码)。图像顶部会告诉您使用的SQL($queryBuilder->getDql())。从图中可以看到,页
这是我的控制器代码
public function searchAction() {
$recordsPerPage = 100;
if ($this->request->isGet()) {
$form = new DirectorySearchForm();
$directory = new DirectoryModel();
$form->setInputFilter($directory->getInputFilter());
$form->setData($this->request->getQuery());
if ($form->isValid()) {
$directoryDao = new DirectoryDao();
$directory->populate($form->getData());
$adapter = new DoctrineAdapter(new ORMPaginator($directoryDao->searchStaffDirectory($this->getEntityManager()->createQueryBuilder(), $directory)));
$paginator = new Paginator($adapter);
$paginator->setItemCountPerPage($recordsPerPage);
$page = (int)$this->params()->fromQuery("page");
$paginator->setCurrentPageNumber($page);
//var_dump();
return array(
"staffList" => $paginator,
"recordCount" => $adapter->count(),
"recordsPerPage" => $recordsPerPage,
);
}
}
return $this->viewModel;
}
<?php
// Declare temporary variables here
$oddEven = array('odd', 'even');
$tempCounter = 0;
?>
Found <?php echo $recordCount; ?> records<br />
<table>
<tr>
<td colspan="4"><a style="text-decoration: none" title="Many different prefixes apply to campus extensions. Click on name or phone number for contact details."><h2>Click on name or phone number for contact details</h2></a></td>
</tr>
<tr>
<th scope="col" class="searchResults highlightOrgStructure">name</th>
<th scope="col" class="searchResults highlightOrgStructure">Telephone</th>
<th scope="col" class="searchResults highlightOrgStructure">Position</th>
<th scope="col" class="searchResults highlightOrgStructure">Department</th>
</tr>
<script type="text/javascript">
$(function () {
$(document).tooltip({
content: function () {
return $(this).prop('title');
}
});
});
</script>
<?php foreach($staffList as $staff) { ?>
<?php ++$tempCounter; ?>
<tr class="<?php echo $oddEven[$tempCounter % 2]; ?>">
<td class="searchResults"><?php echo $staff->surname; if (strlen($staff->firstname) > 0) { echo ", ". $staff->firstname . " " . $staff->title; } ?></td>
<td class="searchResults"><?php echo $staff->telephoneNumber; ?></td>
<td class="searchResults"><?php echo $staff->role; ?></td>
<td class="searchResults"><?php echo $staff->department; ?></td>
</tr>
<?php } ?>
</table>
<?php echo $tempCounter."<hr>"; ?>
我的视图代码
public function searchAction() {
$recordsPerPage = 100;
if ($this->request->isGet()) {
$form = new DirectorySearchForm();
$directory = new DirectoryModel();
$form->setInputFilter($directory->getInputFilter());
$form->setData($this->request->getQuery());
if ($form->isValid()) {
$directoryDao = new DirectoryDao();
$directory->populate($form->getData());
$adapter = new DoctrineAdapter(new ORMPaginator($directoryDao->searchStaffDirectory($this->getEntityManager()->createQueryBuilder(), $directory)));
$paginator = new Paginator($adapter);
$paginator->setItemCountPerPage($recordsPerPage);
$page = (int)$this->params()->fromQuery("page");
$paginator->setCurrentPageNumber($page);
//var_dump();
return array(
"staffList" => $paginator,
"recordCount" => $adapter->count(),
"recordsPerPage" => $recordsPerPage,
);
}
}
return $this->viewModel;
}
<?php
// Declare temporary variables here
$oddEven = array('odd', 'even');
$tempCounter = 0;
?>
Found <?php echo $recordCount; ?> records<br />
<table>
<tr>
<td colspan="4"><a style="text-decoration: none" title="Many different prefixes apply to campus extensions. Click on name or phone number for contact details."><h2>Click on name or phone number for contact details</h2></a></td>
</tr>
<tr>
<th scope="col" class="searchResults highlightOrgStructure">name</th>
<th scope="col" class="searchResults highlightOrgStructure">Telephone</th>
<th scope="col" class="searchResults highlightOrgStructure">Position</th>
<th scope="col" class="searchResults highlightOrgStructure">Department</th>
</tr>
<script type="text/javascript">
$(function () {
$(document).tooltip({
content: function () {
return $(this).prop('title');
}
});
});
</script>
<?php foreach($staffList as $staff) { ?>
<?php ++$tempCounter; ?>
<tr class="<?php echo $oddEven[$tempCounter % 2]; ?>">
<td class="searchResults"><?php echo $staff->surname; if (strlen($staff->firstname) > 0) { echo ", ". $staff->firstname . " " . $staff->title; } ?></td>
<td class="searchResults"><?php echo $staff->telephoneNumber; ?></td>
<td class="searchResults"><?php echo $staff->role; ?></td>
<td class="searchResults"><?php echo $staff->department; ?></td>
</tr>
<?php } ?>
</table>
<?php echo $tempCounter."<hr>"; ?>
找到的记录
单击姓名或电话号码了解联系详细信息
名称
电话
位置
部门
$(函数(){
$(文档)。工具提示({
内容:功能(){
返回$(this.prop('title');
}
});
});