モデルのフィールド情報ファイルを作成
投稿者 aoki 2009 年 12 月 12 日 – 9:50 PM -モデルのフィールド情報ファイルを作成する。(PostgreSQLのみ対応。)
コマンド ( 使う前に cake に path を通しておく)
cake -app /var/www/html/cake_1.2.5/app/ make_table_info
出力先 table_infos ディレクトリを作成 書き込み権限を付与
/var/www/html/cake_1.2.5/app/tmp/table_infos/
モデル名.txt で出力される。
PHP:
-
class MakeTableInfoShell extends Shell
-
{
-
var $controller = true;
-
-
function main()
-
{
-
foreach ($this->uses as $model) {
-
-
//$model = $this->modelClass;
-
attr.attname as column_name
-
,attr.attnotnull as not_null
-
,des2.description as column_comment
-
from
-
pg_catalog.pg_class a inner join pg_catalog.pg_namespace ns on a.relnamespace = ns.oid
-
left join pg_catalog.pg_description des on a.oid = des.objoid
-
and des.objsubid = 0
-
inner join pg_catalog.pg_attribute attr on a.oid = attr.attrelid
-
and attr.attnum> 0
-
left join pg_catalog.pg_description des2 on a.oid = des2.objoid
-
and attr.attnum = des2.objsubid
-
where
-
a.relkind IN ('r', 'v')
-
and ns.nspname IN ('public')
-
and a.relname='%s'
-
order by
-
ns.oid
-
,a.oid
-
,attr.attnum"
-
,$this->$model->useTable
-
);
-
-
$result = $this->$model->query( $sql );
-
-
-
');
-
');
-
$i=0;
-
foreach ($result as $value) {
-
-
if ($i) {
-
');
-
}
-
');
-
');
-
}
-
');
-
');
-
');
-
if ($value[0]["not_null"]) {
-
');
-
} else {
-
');
-
}
-
");
-
-
$i++;
-
}
-
-
fwrite($fp, '$this->table_info_idxs = $this->_set_help_table_info_idxs( $model, $filed , $s_filed , $label, @$link , @$show_index ,@$width);
-
');
-
-
');
-
-
}
-
}
-
-
-
function convert_encoding(&$item, $key){
-
-
-
} else {
-
}
-
}
-
-
}
Tags: cakephp1.2
カテゴリー: PHP | トラックバックURL
