gpt4 book ai didi

php - jQGrid 与 Oracle 数据库

转载 作者:行者123 更新时间:2023-11-28 02:42:31 24 4
gpt4 key购买 nike

我正在使用jqgrid和oracle数据库。根本问题是,看似一切都是正确的,而不仅仅是显示数据库表中的信息。我在这里留下了所有可能对我有帮助的代码。

书.php

<?php
//database setting
$dbuser='system';
$dbpassword='manager';
$database='orcl';
$page = 2;
// get the requested page
$limit = 10;
// connect to the database
$db = oci_connect($dbuser, $dbpassword, $database) or die("Connection Error: " . oci_error());
$result = oci_parse($db, 'SELECT COUNT(*) AS count from aaz');
oci_execute($result);

$row = oci_fetch_array ($result);
$count = $row[0];
if( $count > 0 )
{
$total_pages = ceil($count/$limit);
}
else {
$total_pages = 0;
}

if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
$SQL = "SELECT * FROM aaz where rownum <=$limit ORDER BY id";
$result = oci_parse($db, $SQL) or die("Couldn t execute query.".oci_error());
oci_execute($result);

$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = oci_fetch_array($result,OCI_ASSOC))
{
$responce->rows[$i]['id']=$row[ID];
$responce->rows[$i]['cell']=array($row[ID],$row[FIRSTNAME],$row[LASTNAME],$row[PHONE],$row[EMAIL]);
$i++;
}
echo json_encode($responce);
?>

index.php

    <html>
<head>
<title>jQGrid example</title>
<!-- Load CSS--><br />
<link rel="stylesheet" href="css/ui.jqgrid.css" type="text/css" media="all" />
<!-- For this theme, download your own from link above, and place it at css folder -->
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" type="text/css" media="all" />
<!-- Load Javascript -->
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-pt.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
</head>
<body>
...
<table id="datagrid"></table>
<div id="navGrid"></div>
<p><script language="javascript">
jQuery("#datagrid").jqGrid({
url:'book.php',
datatype: 'json',
colNames:['ID','Nome', 'Apelido', 'Telefone','Email'],
colModel:[
{name:'ID',index:'ID', width:155,editable:false,editoptions:{readonly:true,size:10}},
{name:'FIRSTNAME',index:'FIRSTNAME', width:180,editable:true,editoptions:{size:10}},
{name:'LASTNAME',index:'LASTNAME', width:190,editable:true,editoptions:{size:25}},
{name:'PHONE',index:'PHONE', width:160, align:"right",editable:true,editoptions:{size:10}},
{name:'EMAIL',index:'EMAIL', width:160, align:"right",editable:true,editoptions:{size:10}}
],
rowNum:10,
rowList:[10,15,20,25,30,35,40],
pager: '#navGrid',
sortname: 'no',
sortorder: "asc",
height: 210,
viewrecords: true,
caption:"Example"
});
jQuery("#datagrid").jqGrid('navGrid','#navGrid',{edit:true,add:true,del:true});
</script>
</body>
</html>

我得到的答案是 book.php:

{"页数":2,"总计":2,"记录":"12","行数":[{"id":"1","单元格":["1","fname1","lname1","(000)000-0000","name1@gmail.com"]},{"id":"2","cell":["2","fname1","lname1", "(000)000-0000","name1@gmail.com"]},{"id":"3","cell":["3","fname1","lname1","(000)000 -0000","name1@gmail.com"]},{"id":"4","cell":["4","fname1","lname1","(000)000-0000","name1@gmail.com"]},{"id":"5","cell":["5","fname1","lname1","(000)000-0000","name1@gmail.com "]},{"id":"6","cell":["6","fname1","lname1","(000)000-0000","name1@gmail.com"]},{ "id":"7","cell":["7","fname1","lname1","(000)000-0000","name1@gmail.com"]},{"id":"8","cell":["8","fname1","lname1","(000)000-0000","name1@gmail.com"]},{"id":"9","cell ":["9","fname1","lname1","(000)000-0000","name1@gmail.com"]},{"id":"10","cell":["10 ","fname1","lname1","(000)000-0000","name1@gmail.com"]}]}

有人可以帮助我吗?

最佳答案

分页数据的查询有问题,尝试更改分页的查询:

SELECT * FROM 
(
SELECT / * + FIRST_ROWS (n) * / *, ROWNUM rnum FROM (our query)
WHERE ROWNUM <= limit-sup
)
WHERE rnum > = limit-inf;

希望能帮到你,祝你好运。

关于php - jQGrid 与 Oracle 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12461793/

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