2011-05-01から1ヶ月間の記事一覧

カウントの結果を条件に含める

SQL

HAVINGでおk SELECT customer.*, COUNT(customer_user.id__customer) AS COUNT__customer_user FROM customer LEFT JOIN customer_user ON customer.id = customer_user.id__customer GROUP BY customer.id HAVING 0 < COUNT__customer_user

セレクトボックスで選択されている値を取得

よく忘れるのでメモ。 alert( document.getElementById("hoge").options[ document.getElementById("hoge").selectedIndex ].value );

二重のLEFT JOIN

SQL

DB user::社員 id::社員ID name::社員名 project::案件 id::案件ID name::案件名 id__customer_user__agency::代理店(取引先)社員ID id__customer_user__client::クライアント(取引先)社員ID id__user__main_director::メインディレクター(社員)ID cus…

ステータス付きリンクが変更されてる件

旧:http://twitter.com/home?status=ほげふが 新:http://twitter.com/intent/tweet?text=ほげふが 公式ドキュメント:http://dev.twitter.com/pages/intents いろんなパラメータがあるみたい。 url 指定したURLが自動的に短縮される模様 via 関連付ける…

継承されたメソッドのアクセス修飾子で、親か子のどちらが呼ばれるか変わる件

タイトルが馬鹿ですが、うまく説明できなんだ。 private p(); } private function p() { print "super<br />"; } } class sub extends super { private function p() { print "sub<br />"; } } $o = new super(); //super $o = new sub(); //super protected(public)

LEFT JOIN/RIGHT JOINにANDが使えることをよく忘れるのでメモ

テーブルは以下の通り。 ユーザは複数の部署に所属できる為、中間テーブルbelong_memberを設けている。 user(ユーザ情報テーブル id name belong(所属部署テーブル) id name belong_member(ユーザと所属部署を紐付け) id__belong id__user 取得したい結…

onclickにSmartyから文字列を渡す場合のエスケープ処理

default_modifiersでhtmlを設定している場合 'quotes'だけでOK {~$tmp|escape:'quotes'~} default_modifiersでhtmlを設定していない場合 'quotes'→デフォルト('html')の二重 {~$tmp|escape:'quotes'|escape~} テストコード {~nocache~} <script type="text/javascript"> "); document…

auでPOST時に「このページは見つかりませんでした(404)」の対処法

index.php?id=hoge formタグのactionが空白だとエラー? <form ethod="post" action=""> <input type="submit" name="submit" value="送信" /> </form> なので下記の様に指定すると治った。 <form method="post" action="index.php?id={$smarty.get.id|escape}"> <input type="submit" name="submit" value="送信" /> </form> 調査したところ、 【action=""】と未指定 URLにG…

端末の振り分け

IPではなくユーザエージェントのサンプル。 PCサイト用→http://hoge.jp/ #携帯 RewriteCond %{HTTP_USER_AGENT} DoCoMo [NC,OR] RewriteCond %{HTTP_USER_AGENT} J-PHONE [NC,OR] RewriteCond %{HTTP_USER_AGENT} vodafone [NC,OR] RewriteCond %{HTTP_USER…

default_modifiersのnodefaults

Smarty2から3になったことで仕様が変更された模様。 日本語マニュアル http://www.smarty.net/docs/ja/variable.default.modifiers.tpl では{$var|smarty:nodefaults}となっており、一見Smarty2と同じに見えるが、 英語マニュアル http://www.smarty.net/doc…