1. yum install openssl
2.php install
'./configure' '--with-openssl' '--with-imap-ssl'
Wednesday, May 13, 2009
php smarty submenu
require_once("MySmarty.class.php");
$o_smarty = new MySmarty();
$o_smarty->caching = false;
$o_smarty->cache_lifetime = 3600*168;
if (!$o_smarty->is_cached('top.tpl')) {
$menu=array (
0=>array (
0=>"aaaa",
1=>"adsa",
),
1=>array (
0=>"bbbb",
1=>"dasas",
2=>"sadas",
),
2=>array (
0=>"cccc",
1=>"asdasddsa",
)
);
$o_smarty->assign('menu',$menu);
}//if (!$o_smarty->is_cached('top.tpl'))
$o_smarty->display("testmenu.tpl");
?>
{foreach item=bmenu from=$menu name=bmenu}
{foreach item=smenu from=$bmenu name=smenu}
{if $smarty.foreach.smenu.index==0}
{/foreach}
$o_smarty = new MySmarty();
$o_smarty->caching = false;
$o_smarty->cache_lifetime = 3600*168;
if (!$o_smarty->is_cached('top.tpl')) {
$menu=array (
0=>array (
0=>"aaaa",
1=>"adsa",
),
1=>array (
0=>"bbbb",
1=>"dasas",
2=>"sadas",
),
2=>array (
0=>"cccc",
1=>"asdasddsa",
)
);
$o_smarty->assign('menu',$menu);
}//if (!$o_smarty->is_cached('top.tpl'))
$o_smarty->display("testmenu.tpl");
?>
{foreach item=bmenu from=$menu name=bmenu}
{foreach item=smenu from=$bmenu name=smenu}
{if $smarty.foreach.smenu.index==0}
{$smenu}
- {$smenu}
{else}
{/if}
{/foreach}
{/foreach}
postgresql select distinct with random
select distinct categoryid FROM search_random where categoryid in(select categoryid from search_random order by random() limit 8) limit 4
ERROR: pgsenna2: sen_index_update failed
postgres.conf
・ludia.max_n_sort_result = 100000
・ludia.enable_seqscan = on
・ludia_sen_index_flags = 31
・ludia.max_n_index_cache = 16
・ludia.initial_n_segments = 3000
setting up with big value initial_n_segments it will pass error
・ludia.max_n_sort_result = 100000
・ludia.enable_seqscan = on
・ludia_sen_index_flags = 31
・ludia.max_n_index_cache = 16
・ludia.initial_n_segments = 3000
setting up with big value initial_n_segments it will pass error
postgresql order by count
select count(*), u.user_id
from aaa up
join user u
on u.user_id=up.user_id
where accepted=1
group by user_id
having count(*)>1
order by 1
Tuesday, May 12, 2009
PHP smarty submenu
Here are the code
The PHP code is:
$menu=array();
$query="SELECT * FROM domenii WHERE parentid=0";
$resursa=$obj->query($query);
while($row=$obj->fetcharray($resursa)){
$query1="SELECT * FROM domenii WHERE parentid=".$row['id'];
$resursa1=$obj->query($query1);
if($obj->numrows($resursa1)>0){
$submenu=array();
while($row1=$obj->fetcharray($resursa1)){
$submenu[]=array('type'=>$row1['type'],
'id'=>$row1['id'],
'nume'=>$row1['nume'],
'title'=>str_replace(' ','-', $row1['nume']));
}
}else{$submenu='0';}
$menu[]=array('type'=>$row['type'],
'id'=>$row['id'],
'nume'=>$row['nume'],
'title'=>str_replace(' ','-', $row['nume']),
'submenu'=>$submenu);
}
$obj->assign('menu', $menu);
The HTML (with smarty) code:
The PHP code is:
$menu=array();
$query="SELECT * FROM domenii WHERE parentid=0";
$resursa=$obj->query($query);
while($row=$obj->fetcharray($resursa)){
$query1="SELECT * FROM domenii WHERE parentid=".$row['id'];
$resursa1=$obj->query($query1);
if($obj->numrows($resursa1)>0){
$submenu=array();
while($row1=$obj->fetcharray($resursa1)){
$submenu[]=array('type'=>$row1['type'],
'id'=>$row1['id'],
'nume'=>$row1['nume'],
'title'=>str_replace(' ','-', $row1['nume']));
}
}else{$submenu='0';}
$menu[]=array('type'=>$row['type'],
'id'=>$row['id'],
'nume'=>$row['nume'],
'title'=>str_replace(' ','-', $row['nume']),
'submenu'=>$submenu);
}
$obj->assign('menu', $menu);
The HTML (with smarty) code:
- {$menu[i].nume}
{if is_array($menu[i].submenu)}
- {$menu[i].submenu[j].nume}
{section name=j loop=$menu[i].submenu}
{/section}
{/if}
{section name=i loop=$menu}
{/section}
Compact it like this:
['main_link1'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)
['main_link2'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)
Subscribe to:
Posts (Atom)