Archive for the ‘zend’ Category

 

Zend_Search_Lucene_MultiSearcher

9月 28th, 2013

php luceneで久々にちょっと更新していたら、良さそうなのが・・・ http://framework.zend.com/manual/1.12/en/zend.search.lucene.searching.html と思ったけど中身は自分で書いたのと同じで単純に中で配列に持ってるだけだった。 これから使う方は書かない分良いけど、sortやら何やらは全部書くので特に使う理由が無かった。 phpでもマルチスレッド出来るようにならないかなといつも思ってるけど 毎回マルチプロセスのことがマルチスレッドと出てくるのでちょっと。

Read full article | コメントは受け付けていません。

Atom Feedを出力 | zend framework

6月 26th, 2012

http://framework.zend.com/manual/1.11/en/zend.feed.html http://framework.zend.com/manual/1.11/en/zend.feed.consuming-atom.html http://framework.zend.com/manual/1.11/en/zend.feed.writer.html atom feedを出力します。 // 空のfeedを作成 $feed = new Zend_Feed_Writer_Feed; $feed->setTitle(‘blog.bbtune’); $feed->setLink(‘http://blog.bbtune.com’); $feed->setFeedLink(‘http://blog.bbtune.com/atom’, ‘atom’); $feed->addAuthor(array( ‘name’ => ‘Junichi Otake’, ‘uri’ => ‘http://blog.bbtune.com’, )); $feed->setDateModified(time()); // エントリーを追加 $entry = $feed->createEntry(); $entry->setTitle(‘create an atom feed’); $entry->setLink(‘http://blog.bbtune.com/’); $entry->addAuthor(array( ‘name’ => ‘Junichi Otake’, ‘uri’ => ‘http://blog.bbtune.com’, )); $entry->setDateModified(time()); $entry->setDateCreated(time()); $entry->setDescription(‘generated a feed by zend framework zend_feed_writer’); $entry->setContent(‘generated a […]

Read full article | コメントは受け付けていません。

zend lucene search property check | php

1月 29th, 2012

__issetもないようなのでチェックできないと思っていましたが、以下の方法でプロパティの存在確認が出来ました。 $names = $hit->getDocument()->getFieldNames(); if(in_array(‘title’, $names)) $item['title'] = $hit->title; if(in_array(‘price’,$names)) $item['price'] = $hit->price;

Read full article | コメントは受け付けていません。

property_exists | php

1月 25th, 2012

プロパティの存在判別が出来ないのかという話です。 http://www.php.net/manual/ja/function.property-exists.php > isset() とは対照的に、 プロパティの値が NULL の場合でも property_exists() は TRUE を返します。 これだと思ったら > property_exists() 関数は、マジックメソッド __get を使ってアクセスするプロパティを検出することはできません。 むー。 stdClassの場合。 $o = new stdClass(); var_dump($o->abc); // PHP Notice: Undefined property: stdClass::$abc in test.php on line 5 // NULL var_dump(isset($o->abc)); // bool(false) var_dump(property_exists($o,’abc’)); // bool(false) $o->abc=null; var_dump($o->abc); // NULL var_dump(isset($o->abc)); // bool(false) var_dump(property_exists($o,’abc’)); // bool(true) __get __setを書くと・・・ class […]

Read full article | コメントは受け付けていません。

php zend Lucene pagination

1月 24th, 2012

http://framework.zend.com/manual/1.11/en/learning.lucene.pagination.html なんとなくコメントが面白いので。 検索結果のidだけキャッシュしておいて 次ページのときは、idからデータを取得しろというだけですが この結果のインスタンスのサイズが半端ないので、全部キャッシュするのは無理です。 とりあえず、速度だけ計ってみました。 getDocument 100回 0.10254192352295 sec 0.093567132949829 0.091049194335938 search + 100データ取得 + 1000idをcache 0.86610412597656 sec 0.6905689239502 0.69413304328918 ということで、検索は、キーワードやデータ量でかなり変わりますが、getdocument100回のほうが速いことは分かりました。 ページングとキャッシュを実装しました。 基本的には、ページング以外にキャッシュが利用されることは稀なので、memcachedのメモリは少なめに設定です。

Read full article | コメントは受け付けていません。

gettextで他言語対応 | php

12月 11th, 2011

index.phpに以下のように <?php echo _(‘Here is top page.’); ?> xgettext index.php –from-code=utf-8 -o messages.pot # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE’S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid “” msgstr “” “Project-Id-Version: PACKAGE VERSION\n” “Report-Msgid-Bugs-To: \n” […]

Read full article | コメントは受け付けていません。

convert utf-8 to sjis filter for mobile | zend filter

11月 21st, 2011

mixiモバイルがsjisなので、フィルターを入れる。 SJISに変換するfilterを作る。 http://framework.zend.com/manual/ja/zend.filter.writing_filters.html class Lib_Filter_Encoding_Utf2sjis implements Zend_Filter_Interface { public function filter($value) { return mb_convert_encoding( $value, ‘SJIS’, ‘UTF-8′ ); } } viewにsetFilter $view->setFilterPath(‘/mylib/grow.dev/Lib/Filter/Encoding’,’Lib_Filter_Encoding’)->setFilter( ‘Utf2sjis’ ); (zend通すときはnamespace使わない。

Read full article | コメントは受け付けていません。

set timeout Zend_XmlRpc_Client

9月 4th, 2011

PHP Fatal error: Uncaught exception ‘Zend_Http_Client_Adapter_Exception’ with message ‘Read timed out after 10 seconds’ default timeout is 10 seconds. i set timeout to 60secs with zend_httd_client $httpClient = new Zend_Http_Client(); $httpClient->setConfig(array(‘timeout’ => ’60’)); $xmlrpcClient = new Zend_XmlRpc_Client(‘http://blog.bbtune/’,$httpClient);

Read full article | コメントは受け付けていません。