PHP

YAML で UNIQUE INDEX

uniqueConstraints をつかう。 Crocos\HogeBundle\Entity\Fuga: repositoryClass: Crocos\HogeBundle\Entity\FugaRepository type: entity table: hoge_fuga fields: hoge_id: id: true type: integer hoge_key: type: string length: 255 value: type: text…

OAuthException: An active access token must be used to query information about the current user

Facebook PHP SDK の話。 /me とかを user の access token じゃなくて アプリの access token とかで叩いちゃうと出るんだけど、そもそもその前に getUser() で user_id が 0 じゃないことを確認してから叩いても出ることがあったので調査してた。 signedRe…

php 5.4 debian package memo

https://github.com/crocos/php5-5.4.x-deb わかっているダメな点 php5-sqlite で sqlite.ini と sqlite3.ini が作られてしまう。sqlite.so は作られないのに fpm の config がおかしい (修正済み debug build symbol がやっぱりけされちゃう dh_split しな…

Indirect modification of overloaded property Hoge::$fuga has no effect

PHP

的なエラーがでた。 __get() によって返される値は参照ないから変更したって意味ないよって言う事。 a[$name]; } public function __set($name, $value) { $this->a[$name] = $value; } } $hoge = new Hoge(); に対して、 $hoge->fuga = 1;的なことをした場…

nginx + PHP-FPM な構成で PATH_INFO を受け取る

@ /etc/nginx/conf.d/* location ~ /index.php/ { #fastcgi_split_path_info ^(.+\.php)(.*)$; # <- この設定は、nginx 0.7 以降じゃないとないらしい fastcgi_pass backend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/var/nginx-…

二分木

BTreeを書いた.集合型ということで. setと最小値を取り出すminpopのみサポート.木のバランスが崩れたときの再構築とかは考えていない. num === null) { $this->num = $x; } else { if ($this->num > $x) { $call = "left"; } else…

array_filter と create_function でクイックソート

まーPHP 5.2.x 系以前でこういうことやろうとすると当然create_functionなどというひどいものを使わないといけなかったり。つーか、配列の結合が、+ と array_merge のどっちつかうかは何年PHPつかってても身に付かんな。添字配列と連想配列が一緒くたに扱わ…