原创 [php生成无限级select]用正则遍历数组生成,只查两次数据库收藏

新一篇: MySQLROOT密码忘记怎么办? | 旧一篇: [类别树]寻求从数据库中取出类别树的最高效的办法

修改过很多次。现在基本上不修改了,只查一次数据库,预编正向反向索引。效率是第一流的,我以为它已经做到了效率的极限的好了。

 呵呵,去 7game.net.cn找几个游戏玩玩去

发表于 @ 2005年12月28日 16:58:00|评论(loading...)|编辑

新一篇: MySQLROOT密码忘记怎么办? | 旧一篇: [类别树]寻求从数据库中取出类别树的最高效的办法

评论

#gu1dai 发表于2005-12-28 18:58:00  IP: 221.224.54.*
/**
* Load an array of single field results into an array
*/
function loadResultArray($numinarray = 0 ,$indexKey='',$valueKey='') {
if (!($cur = $this->query())) {
return null;
}
$array = array();
/* 生成数组的key */
if ($indexKey && $valueKey) {
while ($row = mysql_fetch_assoc( $cur )) {
$array[$row[$indexKey]] = $row[$valueKey];
}
}else{
while ($row = mysql_fetch_row( $cur )) {
$array[] = $row[$numinarray];
}
}
mysql_free_result( $cur );
return $array;
}
/**
* Load a assoc list of database rows
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
function loadAssocList( $key='' ) {
if (!($cur = $this->query())) {
return null;
}
$array = array();
while ($row = mysql_fetch_assoc( $cur )) {
if ($key) {
$array[$row[$key]] = $row;
} else {
$array[] = $row;
}
}
mysql_free_result( $cur );
return $array;
}
#gu1dai 发表于2005-12-28 19:39:00  IP: 221.224.54.*
<?
//require("../config.php");
//$userType = $cuserLogin->getUserType();
$userType = 10;
define( '_VALID_MOS', 1 );
require_once("echo.php");
require_once("../../configuration.php");
require_once("../../includes/database.php");
$database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db,$mosConfig_dbprefix );
?>
<html>
<head>
<title>DedeCms menu</title>
<link rel="stylesheet" href="base.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<style>
.tdborder{
border-left: 1px solid #43938B;
border-right: 1px solid #43938B;
border-bottom: 1px solid #43938B;
}
.tdline{
border-bottom: 1px solid #656363;
}
.topitem{cursor: hand;}
body {
scrollbar-base-color:#517CEA;scrollbar-arrow-color:#FFFFFF;
}
*{line-height:1;margin:0px;PADDING:0px;}
</style>
<script language="javascript">
function showHide(obj){
var oStyle = obj.parentElement.parentElement.parentElement.rows[1].style;
oStyle.display == "none" ? oStyle.display = "block" : oStyle.display = "none";
}

function showHide2(obj){
var oStyle = obj.parentElement.parentElement.div[1].style;
#gu1dai 发表于2005-12-29 16:01:00  IP: 221.224.54.*
包含全部测试数据和代码

http://gudai.cnblogs.com/articles/307321.html
发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © gu1dai