dooPHP带表名前缀的表生成模型为单独文件

  • 作者:scsidisk
  • 最后编辑:2011年02月13日
  • 标签: DooPHP, PHP

修改 dooframework/db/DooModelGen.php


public static function gen_mysql($comments=true, $vrules=true, $extends=’DooModel’, $createBase=true, $baseSuffix=’Base’, $chmod=null) {

self::genMySQL($comments, $vrules, $extends, $createBase, $baseSuffix, $chmod);

public static function genMySQL($comments=true, $vrules=true, $extends=’DooModel’, $createBase=true, $baseSuffix=’Base’, $chmod=null, $tablePrefix=null) {

$classname = ‘’;

if($tablePrefix){

$temptbl = str_replace($tablePrefix,’’,$tblname);

}else{

$temptbl = $tblname;

}



public static function gen_mysql($comments=true, $vrules=true, $extends=’DooModel’, $createBase=true, $baseSuffix=’Base’, $chmod=null, $tablePrefix=null) {

self::genMySQL($comments, $vrules, $extends, $createBase, $baseSuffix, $chmod, $tablePrefix);

public static function genMySQL($comments=true, $vrules=true, $extends=’DooModel’, $createBase=true, $baseSuffix=’Base’, $chmod=null, $tablePrefix=null) {

$classname = ‘’;

if($tablePrefix){

$temptbl = str_replace($tablePrefix,’’,$tblname);

}else{

$temptbl = $tblname;

}


修改控制器 MainController.php


public function gen_model(){

Doo::loadCore(‘db/DooModelGen’);

DooModelGen::genMySQL(true,true, ‘DooModel’, false, ‘Base’, null);

}



public function gen_model(){

Doo::loadCore(‘db/DooModelGen’);

DooModelGen::genMySQL(true,true, ‘DooModel’, false, ‘Base’, null, ‘tb_’);

}


… 为省略的部分,自己搜索一下。 重新生成模型即可。不生成 Base 目录,直接生成单独的 model 文件,如果想生成 Base , 把 第四个 false 改成true 即可。