- 注册时间
- 2012-9-9
- 最后登录
- 2018-4-2
- 阅读权限
- 10
- 积分
- 41
- 精华
- 0
- 帖子
- 11
|
本帖最后由 dirma 于 2012-9-11 20:54 编辑
listtree json 格式问题:
情况一 OK
[
{ "id":"00001","text":"00001","pid":"00000"},
{ "id":"00002","text":"00002","pid":"00001"},
{ "id":"00003","text":"00003","pid":"00001"}
]
情况二 出错
[
{ "ID":"00001","TEXT":"00001","ID":"00000"},
{ "ID":"00002","TEXT":"00002","ID":"00001"},
{ "ID":"00003","TEXT":"00003","ID":"00001"}
]
情况三 ok
[
{ id:"00001",text:"00001",pid:"00000"},
{ id:"00002",text:"00002",pid:"00001"},
{ id:"00003",text:"00003",pid:"00001"}
]
BUG1 :对于最常见的第2格式不支持,因为ORACLE 输出是大写的"ID","TEXT","ID",该怎么办 ?请指导 ;
效率 BUG 2 :弹出多选树:MultiSelectTree 弹出多选树对于多选树加载后,点击2级节点后 ,下面所有节点均打开了, 对于大的层次较多的节点效率较差,如何实现点击2级节点只打开3级节点而不是展开所有的节点。
BUG 3 弹出多选树:MultiSelectTree 弹出多选树 查询不行
效率比较:大家看看下面三种写法,那种加载树的效能最快。
具体测试环境 PHP (5.4.5)+ORACLE(11G R2) 加载数据5000条
tree.php ok
------------------------------------------------------------------------------
<?php
header('Content-Type: text/html;charset=utf-8');
$c = oci_pconnect("scott", "tiger","local/mydbOOLED","utf8");
$s = oci_parse($c, 'select /* +result_cache */ * from tree ');
oci_execute($s);
//重新整理成id
$tree = array();
while ($row = oci_fetch_array($s, OCI_ASSOC))
{
$node = array(
'id' => $row["ID"],
'text' => $row["TEXT"],
'pid' => $row["ID"]
);
array_push($tree, $node);
}
$json_tree = json_encode($tree,JSON_UNESCAPED_UNICODE);
echo $json_tree;
oci_free_statement($s);
oci_close($c);
?>
------------------------------------------------------------------------------
listtree.php 出错
<?php
header('Content-Type: text/html;charset=utf-8');
$c = oci_pconnect("scott", "tiger","local/mydbOOLED","utf8");
$s = oci_parse($c, 'select /* +result_cache */ * from tree ');
oci_execute($s);
//得到大写ID
echo '[';
while (($row = oci_fetch_object($s)))
{
if ($row->ID == '0000013')
{
echo json_encode($row,JSON_UNESCAPED_UNICODE);
}
else{
echo ",".json_encode($row,JSON_UNESCAPED_UNICODE);
}
}
echo ']';
oci_free_statement($s);
oci_close($c);
?>
------------------------------------------------------------------------------
MultiTree.php ok
<?php
$c = oci_pconnect("scott", "tiger","local/mydbOOLED","utf8");
$s = oci_parse($c, 'select /* +result_cache */ * from tree ');
oci_execute($s);
/*字符串拼接 */
echo "[";
while ($row = oci_fetch_array($s, OCI_ASSOC))
{
if ($row["ID"]=='0000013')
{
echo "{";
echo " id: ";echo json_encode($row["ID"]);
echo ", text: ";echo json_encode($row["TEXT"],JSON_UNESCAPED_UNICODE);
// echo "{pid;".$row["ID"];
echo ", expanded: true"; //打开所有接点
echo "}";
}
elseif ($row["ID"]=='0000013') {
echo ",{";
echo " id: ";echo json_encode($row["ID"]);
echo ", text: ";echo json_encode($row["TEXT"],JSON_UNESCAPED_UNICODE);
echo ", pid: ";echo json_encode($row["ID"]);
echo ", expanded: false";
echo "}";
}
else{
echo ",{";
echo " id: ";echo json_encode($row["ID"]);
echo ", text: ";echo json_encode($row["TEXT"],JSON_UNESCAPED_UNICODE);
echo ", pid: ";echo json_encode($row["ID"]);
echo ", expanded: false";
echo "}";
}
}
echo "]";
oci_free_statement($s);
oci_close($c);
?>
|
|