The attribute of the mysqldate_key field is date. after a model is created using laraveleloquent, the all () method is used. the date_key field returns only the year. I don't know whether the time format of the model needs to be set or what is the problem. please advise. The code is as follows: Model: classRpt_ep_readextendsModel {{...
The attribute of the mysql date_key field is date,
Create a model using laravel eloquent and use the all () method. the date_key field returns only the year.
I don't know whether the time format of the model needs to be set or what is the problem. please advise. The code is as follows:
Model:
Class Rpt_ep_read extends Model
{
//protected $table = 'rpt_ep_read';protected $primaryKey = 'date_key';
}
Controller
Use AppModelsRptdataWebRpt_ep_read;
Class TestController extends Controller {
Public function test (){
$data = Rpt_ep_read::all(); return $data;
}
}
Return value:
Mysql
CREATE TABLErpt_ep_read
(
date_key
Date not null comment 'time ',
cust_num
Int (11) not null comment 'users ',
Primary key (date_key
)
) ENGINE = InnoDB default charset = utf8 COLLATE = utf8_unicode_ci;
DB: table ()-> get () can return normal results
Reply content:
The attribute of the mysql date_key field is date,
Create a model using laravel eloquent and use the all () method. the date_key field returns only the year.
I don't know whether the time format of the model needs to be set or what is the problem. please advise. The code is as follows:
Model:
Class Rpt_ep_read extends Model
{
//protected $table = 'rpt_ep_read';protected $primaryKey = 'date_key';
}
Controller
Use AppModelsRptdataWebRpt_ep_read;
Class TestController extends Controller {
Public function test (){
$data = Rpt_ep_read::all(); return $data;
}
}
Return value:
Mysql
CREATE TABLErpt_ep_read
(
date_key
Date not null comment 'time ',
cust_num
Int (11) not null comment 'users ',
Primary key (date_key
)
) ENGINE = InnoDB default charset = utf8 COLLATE = utf8_unicode_ci;
DB: table ()-> get () can return normal results
In yourModel
Addpublic $incrementing = false;
OtherwiseLaravel
The default primary key is auto-increment and is convertedint
Return