Workman Version:4.1.2
PHP Version: 8.1.10
OS:macOS 12.6
webman framework: 1.4.3
數(shù)據(jù)庫連接正常
使用
php webman make:model mngWkInfo
期望生成一個Model類,類的內(nèi)容帶著字段的名稱
namespace app\model;
use support\Model;
/**
* @property string $created_at
* @property string $deleted_at
* @property integer $id (主鍵)
* @property string $idx_code 指數(shù)編碼
* @property string $idx_name 指數(shù)名稱
* @property string $pct_change 漲跌幅
aindexeodprices.s_dq_pctchange
* @property string $trade_date 交易日期
* @property string $updated_at
*/
class MngWkInfo extends Model {
protected $table = 'mng_wk_info';
}
而現(xiàn)在生成的類是
<?php
namespace app\model;
use support\Model;
/**
*
*/
class MngWkInf extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = null;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
}
貌似沒有讀取表里的內(nèi)容,我不知道是不是升級了新版本的webman后需要新的配置,我在文檔里也沒有看到相關(guān)的介紹。
make:model
是 webman/console
組件提供的,一般和webman升級沒有關(guān)系。
沒有生成注釋一般是因為命令里沒有成功連接到主配置的數(shù)據(jù)庫,或者表不存在,至于為什么需要你自己排查下。
文件 vendor/webman/console/src/Commands/MakeModelCommand.php 的 createModel方法
經(jīng)過debug,發(fā)現(xiàn)一個問題,我不知道為啥會這樣。 上述類中createModel方法第95行的代碼,$table = Util::classToName($class); 當(dāng)我們傳入的類名是 mngWkInfo時,$table的返回值是 mng_wk_infos , 自己給字段增加了s后綴,這樣,在108行循環(huán)的時候,這個表里在庫里自然是沒有的,我不知道Util::classToName()這個函數(shù)為什么會這樣