【发布时间】:2019-07-08 20:12:54
【问题描述】:
我正在尝试从根据日期不断更改其后缀的表中提取数据。例如 6 月的 Report201906,7 月的 Report201907。
所以我想连接到具有当前日期后缀的表。例如,当前月份是 7 月。所以我想连接到 Report201907
我试过了:
protected $connection = 'mysql2';
protected $primaryKey = 'id';
protected $current_month = date('Ym',strtotime(date('Y-m')." -1 month"));
protected $table = 'Report'.$current_month; //Hoping to connect to Report201907
但我得到了错误 常量表达式包含无效操作。我对 laravel 和 PHP 还很陌生。非常感谢您的帮助。
【问题讨论】:
-
不能直接赋值给属性,但是可以在构造函数中设置
-
我讨厌成为“那个人”,但为什么要将报告存储在特定日期的表格下?它没有理由被称为关系数据库;)