2010年11月11日木曜日

PL/pgSQLのソースコード確認方法

PostgreSQLに登録したPL/pgSQLの内容を確認する方法

-----------------------------------------
SELECT routine_definition
FROM information_schema.routines
WHERE routine_name = '(関数名)';
-----------------------------------------

(例)
=#
CREATE OR REPLACE FUNCTION hogehoge(INTEGER) RETURNS VOID AS $$
DECLARE

BEGIN

END;
$$ LANGUAGE plpgsql;

=#
SELECT routine_definition
FROM information_schema.routines
WHERE routine_name = 'hogehoge'

-----------------------------------------

参考URL

2010年10月21日木曜日

propelでdoUpdate

Propelで複数行を条件指定でまとめて更新する場合

UPDATE (テーブル) SET カラム = 値 WHERE (条件)
をPropelで書くときのメモ

-------------------------------------------------

$update = new Criteria();
$where = new Criteria();

// 更新する内容を設定
$update->add(カラム名1, 値);
$update->add(カラム名2, 値);

// 更新対象を抽出するWhere句
$where->addAnd(カラム名3, 値);
$where->addAnd(カラム名4, 値);

// コネクションを取得
$con = Propel::getConnection(DB名);

// 更新処理
BasePeer::doUpdate($where, $update, $con);


-------------------------------------------------

Update テーブル
SET カラム名1 = 値, カラム名2 = 値
WHERE カラム名3 = 値
AND カラム名4 = 値

参考URL

2010年9月9日木曜日

Unable to get sequence id

symfony に Unable to get sequence id. と言われた、そんなとき
http://unicus.jp/wp/archives/43

symfony1.4 + Postgresqlで発生

lib/vendor/propel-generator/classes/propel/engine/platform/PgsqlPlatform.php
getSequenceName が32のため発生している

2010年8月27日金曜日

symfony1.4でのプロジェクト作成コマンド

symfony1.4

Propelを利用する場合のプロジェクト生成
>symfony generate:project (プロジェクト名) --orm=propel


アプリケーション生成
>symfony generate:app (アプリケーション名)


モジュール生成
>symfony generate:module (アプリケーション名) (モジュール名)

2010年8月10日火曜日

csvが文字化け

SJIS-winで出力しているCSVがUTF-8として認識される現象が発生

http://www.okushin.co.jp/kodanuki_note/2009/09/csv.html

require,includeで読み込んでいるPHPファイルの中にBOM付UTF-8が混入していた為

2010年7月13日火曜日

phpでpostgreSQLに接続できない

windows用PHP5.6以降のphp_pgsql.dllは壊れている模様


最低すぎる・・・

2010年6月30日水曜日

centos 備忘録

================================================================================
【CentOS】
■インストール情報
@link http://itochif.com/contents/Linux/centos5/install_011.html



================================================================================
【mysql】


@link http://centos.server-manual.com/centos5_mysql.html

※mysql起動時にタイムアウトエラー発生
# /etc/rc.d/init.d/mysqld start
Timeout error occurred trying to start MySQL Daemon.

以下のコマンドのみで解決
# mysql_install_db

※外部ホストからアクセスできない
→linuxのポートが閉じていたためiptablesに以下の設定を追記
/etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

→iptablesを再起動
> service iptables restart


※mysqldumpのデータをインポート時に「max_allowed_packet」でエラー発生
→設定ファイルに以下の設定を追記

/etc/my.cnf
[mysqld]
max_allowed_packet = 32M

================================================================================
【ruby】
ruby-1.8.7-p249
#ruby-1.9.1-p378 redmineが未対応のため1.8.7を後からインストール
rubygems-1.3.6.tgz
rake 0.8.7

--------------------------------------------------------------------------------
※# gem install rails でエラー
/usr/local/ruby//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- zlib (LoadError)

→zlibがインストールされていないため
→インストールしてもzlibのrequireに失敗

以下解決方法
@link http://born1981.g.hatena.ne.jp/uzulla/20080131/1201765333

# cd /root/ruby-1.9.1-p378/ext/zlib
# ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
# make all
# make install
--------------------------------------------------------------------------------


# gem install rails
# gem install rake


※ # rake load_default_data RAILS_ENV=production --trace でエラー
redmineがruby1.9に未対応

http://groups.google.com/group/redmine-users-ja/browse_thread/thread/0bb3e28097f50b4f


================================================================================
【rails】
# rails -v
Rails 2.3.5


================================================================================
【subversion】
# svnadmin --version
svnadmin, バージョン 1.4.2 (r22196)



================================================================================
【vsftpd】











================================================================================
参考サイト

http://www.sakuttoly.com/blog/2009/04/redmine_passenger_centos.html
http://www.sakuttoly.com/blog/2010/01/redmine-centos.html


http://synth.jp/pg/2007/05/rails_mongrel.html
http://redmine.jp/guide/RedmineInstall/
http://redmine.jp/tech_note/apache-passenger/
http://mylinux.g.hatena.ne.jp/teraco/20081129/1228133066
http://blog.mizoshiri.com/archives/166
http://born1981.g.hatena.ne.jp/uzulla/20080131/1201765333
http://blog.apecell.com/2008/04/02/id/38
http://blog.apecell.com/2008/04/02/id/38
http://dev.chrisryu.com/2007/02/redmine_1.html
http://blog.mizoshiri.com/archives/166
http://it.kndb.jp/entry/show/id/1134
http://centos.server-manual.com/centos5_mysql.html
http://mylinux.g.hatena.ne.jp/teraco/20081129/1228133066



SVN連携
http://redmine.jp/tech_note/subversion/
http://redmine.jp/faq/repository/shift_jisutf-8/



apache
http://itochif.com/contents/Linux/centos5/web/apache_00100.html
http://itochif.com/contents/Linux/centos5/operation_0021.html


Apache VirtualHostでDocumentRoot does not exist でもあるのに。。
http://kennyqi.com/item/81
http://park1.wakwak.com/~ima/centos4_apache0002.html


IP変更
http://blog.veryposi.info/server/server-setup/centos-dhcp-ip/


subversion
http://park1.wakwak.com/~ima/centos4_subversion0001.html


mysql
http://www.boxboost.com/webtech/JSP/mysql_linux/mysql_A3.jsp



http://mirror.its.uidaho.edu/pub/centos/5.4/isos/i386/

http://kajuhome.com/centos5_inst.shtml
http://pc-os.seesaa.net/article/38943394.html


http://itochif.com/contents/Linux/centos5/install_011.html
http://itochif.com/contents/Linux/centos5/web/apache_00100.html


http://itochif.com/contents/Linux/centos5/

2010年6月16日水曜日

CSR発行手順

[CSR出力方法]
※windows

Apache2\bin\

・乱数生成
>openssl md5 * > rand.dat

・秘密鍵生成
>openssl genrsa -rand rand.dat -des3 1024 > server_pass.key

・パスフレーズを削除した秘密鍵を生成
※Windowsでは必須:Apacheがパスフレーズありで起動できないため
>openssl rsa -in server_pass.key -out server.key

・CSR生成
>openssl req -new -key server.key -out server.csr

C=JP
ST=Tokyo
L=Chiyoda-ku
O=組織名
OU=部署名
CN=www.hogehoge.com

・CSR確認(CSR生成で入力した内容が表示されればOK)
>openssl req -in server.csr -noout -text

2010年4月2日金曜日

propelで別名をつけてJOIN

以下のような同じテーブルをJoinして別名を付与する場合

SELECT `order_main`.*, `c1`.*, `c2`.*
FROM `order_main`
INNER JOIN `customer` `c1` ON `order_main`.`customer_id` = `c1`.`id`
INNER JOIN `customer` `c2` ON `c1`.`friend_id` = `c2`.`id`;

----------------------------------------------------------------

$criteria = new Criteria();

$c = clone $criteria;

// 顧客
$c->addAlias( 'c1', CustomerPeer::TABLE_NAME );
$c->addJoin( OrderMainPeer::CUSTOMER_ID, CustomerPeer::alias( 'c1', CustomerPeer::ID ), Criteria::INNER_JOIN );


// 顧客(紹介元)
$c->addAlias( 'c2', CustomerPeer::TABLE_NAME );
$c->addJoin( CustomerPeer::alias( 'c1', CustomerPeer::FRIEND_ID ), CustomerPeer::alias( 'c2', CustomerPeer::ID ), Criteria::LEFT_JOIN );


//---------------------
// カラム設定
//---------------------
// 受注
OrderMainPeer::addSelectColumns( $c );


// 顧客
$c_temp = clone $criteria;
CustomerPeer::addSelectColumns( $c_temp );
foreach( $c_temp->getSelectColumns() as $column )
{
$c->addSelectColumn( CustomerPeer::alias( 'c1', $column ) );
}


// 友達
$c_temp = clone $criteria;
CustomerPeer::addSelectColumns( $c_temp );
foreach( $c_temp->getSelectColumns() as $column )
{
$c->addSelectColumn( CustomerPeer::alias( 'c2', $column ) );
}


//-----------------------------
// 検索実行して結果を取得する
//-----------------------------
$rs = BasePeer::doSelect( $c );
$res = array( );

while( $result = $rs->fetch( ) )
{
$order_main = new OrderMain( );
$order_main->hydrate( $result );
$pos = self::NUM_COLUMNS - self::NUM_LAZY_LOAD_COLUMNS;

$c1 = new Customer();
$c1->hydrate( $result, $pos );
$pos += CustomerPeer::NUM_COLUMNS;

$c2 = new Customer();
$c2->hydrate( $result, $pos );

$c1->setCustomerRelatedByFriendId($c2);

$order_main->setCustomer($c1);

$res[] = $order_main;
}

return $res;

----------------------------------------------------------------

symfony1.4でのBasePeer::doSelect()の返却値は
PDOstatementなので
以前の->next()は使用できない

外部参照制約を宣言してある場合は
Base~Peerのfunction get~RelatedBy~() とかが参考になります

2010年3月31日水曜日

symfony flashが消える・・

symfony1.4でflashの値が削除される現象が発生しました
(他バージョンでは不明)

redirectで遷移した場合には保持できているのに
リンクなどで遷移するとflashが削除されていました

Attributeの値は保持されているので
セッションが切断されていないことはすぐわかったのですが
何故か画面表示後のリンククリックなどでの遷移でのみ発生


なぜ発生するのか過程は調査していませんが
テンプレートにimgタグのリンク先を間違えているためでした


推測ですが
imgのリンク先が誤っていた場合
.htaccessによりフロントコントローラーに処理が渡され
遷移として処理されるためにFlashがクリアされてる予感


※このエラー原因特定までにすごい時間かかりました
'・ω・`)

2010年3月26日金曜日

各キャリアでのマーキーの対応(marquee)

各キャリア毎のマーキー表示について

http://symple.jp/18.html

http://symple.jp/47.html

2010年3月17日水曜日

sfValidatorRegex パターン以外を正常とする

パターンにマッチしないものが正常

new sfValidatorRegex( array('pattern' => '/~/', 'must_match' => false));

must_matchオプションをfalseに設定する

※symfony1.3,1.4のみ有効


2010年3月11日木曜日

symfony 404 Not Found カスタマイズ

http://www.centsys.jp/service/technical_information/symfony/etc/20080517-2.html


symfony で404 not foundを任意のページに変更する。

app/config/setting.yml

default:
.actions:
error_404_module: error
error_404_action: error404Page

2010年3月9日火曜日

2010年3月5日金曜日

ArrayAccess インターフェイス

http://php.net/manual/ja/class.arrayaccess.php

配列としてオブジェクトにアクセスするための機能のインターフェイスです。


widgetSchema 配列と validatorSchema 配列は、
実際にはそれぞれ sfWidgetFormSchemasfValidatorSchema と呼ばれる特殊なクラスで、
ArrayAccess インターフェイスを実装しています。

2010年3月4日木曜日