2007年1月アーカイブ

カテゴリー:

カテゴリー:

カテゴリー:

symfony PHP5 framework

Retrieve information about the current route

If you need to retrieve information about the current route, for instance to prepare a future 'back to page xxx' link, you should use the methods of the sfRouting object. For instance, if your routing.yml defines:

my_rule:
  url:   /call_my_rule
  param: { module: mymodule, action: myaction }
Use the following calls in the action:

// if you require an URL like
http://myapp.example.com/call_my_rule/param1/xxx/param2/yyy
 
$uri = sfRouting::getInstance()->getCurrentInternalUri();
// will return 'mymodule/myaction?param1=xxx¶m2=yyy'
 
$uri = sfRouting::getInstance()->getCurrentInternalUri(true);
// will return '@myrule?param1=xxx¶m2=yyy'
 
$route = sfRouting::getInstance()->getCurrentRouteName();
// will return 'myrule'

The URIs returned by the ->getCurrentInternalUri() method can be used in a call to a link_to() helper.

In addition, you might want to get the first or the last action called in a template. The following variables are automatically updated at each request and are available to templates:

$sf_first_action
$sf_first_module
$sf_last_action
$sf_last_module

カテゴリー:

Code Snippets

Complement complex SQL in SYMFONY
http://propel.phpdb.org/trac/ticket/57

集計関数を使用する例
SELECT MIN(reserve.MINUTES_PER_UNIT), reserve.NUMBER_PER_UNIT
FROM reserve
WHERE reserve.TYPE='time' AND reserve.RESERVE_GROUP_ID=1
GROUP BY reserve.TYPE,reserve.RESERVE_GROUP_ID
$c = new Criteria();
$c->add(ReservePeer::TYPE, $reserve_type);
$c->add(ReservePeer::RESERVE_GROUP_ID, $reserve_group_id);
$c->addSelectColumn('MIN('.ReservePeer::MINUTES_PER_UNIT.')');
$c->addGroupByColumn(ReservePeer::TYPE);
$c->addGroupByColumn(ReservePeer::RESERVE_GROUP_ID);
$rs = ReservePeer::doSelectRS($c);
while ($rs->next())
{
  $minutes_per_unit = $rs->getInt(1);
}

カテゴリー:

ITmedia エンタープライズ:Windows Tips「「ようこそ」画面に特定のユーザーを表示させないようにする」

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
に、非表示にしたいアカウント名のDWORD値を作成して、値を0にする。

Windows Vistaでも同じ方法でアカウントを非表示にできる。

カテゴリー:

http://www.symfony-project.com/book/trunk/file_structure

symfonyのディレクトリパスは、sfConfigで取得できる。

// root directory structure
'sf_cache_dir_name'   => 'cache',
'sf_log_dir_name'     => 'log',
'sf_lib_dir_name'     => 'lib',
'sf_model_dir_name'   => 'model',
'sf_web_dir_name'     => 'web',
'sf_data_dir_name'    => 'data',
'sf_config_dir_name'  => 'config',
'sf_apps_dir_name'    => 'apps',
 
// global directory structure
'sf_app_dir'        => $sf_root_dir.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$sf_app,
'sf_model_dir'      => $sf_root_dir.DIRECTORY_SEPARATOR.'model',
'sf_lib_dir'        => $sf_root_dir.DIRECTORY_SEPARATOR.'lib',
'sf_web_dir'        => $sf_root_dir.DIRECTORY_SEPARATOR.'web',
'sf_upload_dir'     => $sf_root_dir.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.'uploads',
'sf_base_cache_dir' => $sf_root_dir.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$sf_app,
'sf_cache_dir'      => $sf_root_dir.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$sf_app.DIRECTORY_SEPARATOR.$sf_environment,
'sf_log_dir'        => $sf_root_dir.DIRECTORY_SEPARATOR.'log',
'sf_data_dir'       => $sf_root_dir.DIRECTORY_SEPARATOR.'data',
'sf_config_dir'     => $sf_root_dir.DIRECTORY_SEPARATOR.'config',

カテゴリー:

ITエンジニアにも必要な国語力(1)

ITエンジニアにも必要な国語力

カテゴリー:

UNIX環境へのPHPインストール - phpspot

UNIX環境へのPHPインストール

カテゴリー:

  • forward時には、各action間で$thisのプロパティは引き継がれない。
  • forward時には、各actionで毎回preExecuteとpostExecute()が実行される。
  • validationは、actionの実行前に行われるため、validateXxxx()、handleErrorXxxx()の実行時には、preExecute()、postExecute()は実行されない。

カテゴリー: