MySQL Date_key field property is date,
Using the All () method after creating the model with Laravel eloquent, the Date_key field returns only the year.
Do not know whether the model time format to set or what the problem, seek guidance. 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 TABLE rpt_ep_read
(
date_key
Date not NULL COMMENT ' time ',
cust_num
Int (one) not NULL COMMENT ' number of users ',
PRIMARY KEY ( date_key
)
) Engine=innodb DEFAULT Charset=utf8 collate=utf8_unicode_ci;
Use Db::table ()->get () to return normally
Reply content:
MySQL Date_key field property is date,
Using the All () method after creating the model with Laravel eloquent, the Date_key field returns only the year.
Do not know whether the model time format to set or what the problem, seek guidance. 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 TABLE rpt_ep_read
(
date_key
Date not NULL COMMENT ' time ',
cust_num
Int (one) not NULL COMMENT ' number of users ',
PRIMARY KEY ( date_key
)
) Engine=innodb DEFAULT Charset=utf8 collate=utf8_unicode_ci;
Use Db::table ()->get () to return normally
Add it to your Model
bottom public $incrementing = false;
, or the Laravel
default primary key is self-increment, and it turns into a int
return