ECSHOP商品属性调用到任意页面方法

看到标题有的人觉得这个很复杂,其实这个没那么复杂,直接用下面的方法,就可以在ECSHOP的任意页面调用商品属性。

一)打开includes\lib_insert.php文件,在最后面增加一个函数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function insert_attr($arr)  
{
static $static_res = NULL;
$aid= isset($arr['aid'])?$arr['aid']:0;
$gid= isset($arr['gid'])?$arr['gid']:0;
if($aid==0) return '';
if ($static_res[$aid][$gid] === NULL)
{
if($gid>0)
{
$static_res[$aid][$gid] = $GLOBALS['db']->getOne('select attr_value from ' . $GLOBALS['ecs']->table('goods_attr') . " where attr_id ='$aid' and goods_id='$gid' ");
}
else
{
$static_res[$aid][$gid] = $GLOBALS['db']->getOne('select attr_name from ' . $GLOBALS['ecs']->table('attribute') . " where attr_id ='$aid' ");
}
}
return $static_res[$aid][$gid];
}

注意要加在 ?> 的前面。

Read More

MySQL优化实例

在Apache, PHP, MySQL的体系架构中,MySQL对于性能的影响最大,也是关键的核心部分。对于Discuz!论坛程序也是如此,MySQL的设置是否合理优化,直接 影响到论坛的速度和承载量!同时,MySQL也是优化难度最大的一个部分,不但需要理解一些MySQL专业知识,同时还需要长时间的观察统计并且根据经验 进行判断,然后设置合理的参数。

下面我们了解一下MySQL优化的一些基础,MySQL的优化我分为两个部分,一是服务器物理硬件的优化;二是MySQL自身(my.cnf)的优化。

Read More

Jquery多选框互相内容交换

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

// 把选择项追加给对方
$('#add').click(function(){
var options=$('#select1 option:selected');
var remove=options.remove();
remove.appendTo("#select2");
});

// 把所有项追加给对方
$('#addAll').click(function(){
var options=$('#select1 option');
var remove=options.remove();
remove.appendTo("#select2");
});

// 把选择项退回给对方
$('#remove').click(function(){
var options=$('#select2 option:selected');
var remove=options.remove();
remove.appendTo("#select1");
});

// 把全部项退回给对方
$('#removeAll').click(function(){
var options=$('#select2 option');
var remove=options.remove();
remove.appendTo("#select1");
});

});
</script>

</head>
<body>
<form id="form1" runat="server">
<div id="left">
<select multiple="multiple" id="select1" style="width:100px;height:160px">
<option>选项1</option>
<option>选项2</option>
<option>选项3</option>
<option>选项4</option>
<option>选项5</option>
</select>
</div>
<div>
<span id="add">选中项添加至右边>></span><br />
<span id="addAll">全部添加到右边>></span>
</div>

<div id="right">
<select multiple="multiple" id="select2" style="width:100px;height:160px"></select>
</div>
<div>
<span id="remove"><<选中项还原至左边</span><br />
<span id="removeAll"><<全部还原至左边</span>
</div>
</form>
</body>