Posts Tagged 程式
找出Table 中 資料相同的Record
因為有遇到這個問題
所以特別寫出來備忘
SELECT *
FROM bb_downloads a
WHERE
(SELECT count( * )
FROM bb_downloads b
WHERE b.post_id = a.post_id
AND b.url = a.url
) >1
ORDER BY `post_id`,`download_times` DESC
UPDATE: 2007/10/14
找出不相同的資料
非常的easy
select r.user_id from rtable r WHERE r.user_id not in (select a.user_id from atable a)
刪除不相同的資料
delete from rtable WHERE user_id not in (select a.user_id from atable a)
待解決….
1.slow query
2.search engine -> mod_rewrite
3.imagick -> fetch -> resize .
他媽的我寫這什麼爛code ………….
::(:
gettext command 備忘
xgettext – extract gettext strings from source
xgettext *.php
msgfmt – compile message catalog to binary format
msgfmt -cv message.po
怕自已忘記…又要找很討厭….
smarty rawurldecode plugin …..
因為我在smarty 上不能直接用php的rawurldecode ,所以自已寫了一個smarty 的function 傳回rawurldecode 過的值給smarty 就這樣而已…..
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_function_rawurldecode ($params, &$smarty) {
if (empty($params['lastpage_url'])){
$smarty->_trigger_fatal_error(“[rawurldecode] param lastpage_url cannot be empty”);
return;
}
if (isset($params['lastpage_url'])){
$return = $params['lastpage_url'];
$return = rawurldecode($return);
}
return $return;
}
?>
reference…
How to write a custom Smarty function in php
h):
Gallery 2.2 windows 上傳問題!!
程式的功力差別!!!!
今天在寫apollo的ad 部份
有一個部份是在實做百面骰的部份
用百面骰的概念來實做百分比的呈現
例如我有5個值
a 的 比例是20,
b 的 比例是30,
c 的 比例是50,
d 的 比例是80,
f 的 比例是160
然後依比例來讓他們呈現應有的次數
最直接想的是
直接塞個20+30+50+80+160 的array
不過覺得這樣做實在是挺白痴的
覺得應該有更好的方法
經過”貓哥”的小小提示”區間”
我想到的是
$rand = rand(1,$ad_total);
用for 來做
if (0 <= $rand<= a){
return a;
} elseif ( a < $rand <=b ){
return b;
}
一直下去。
不過貓哥寫的是這樣
$rand = rand(1,$ad_total);
for ($i=0; $i
if ($rand < 0) {
break;
}
}
一看就覺得我自已像笨蛋一樣…………………..
有很深的体會,程式寫的好的和不好的差別,真的是一眼就看出來了。 ::S: