klasss Posted December 19, 2021 at 01:41 PM Report Share #624973 Posted December 19, 2021 at 01:41 PM Olá, Estou aqui com um pequeno problema ao gravar uma data na BD. $datatest= date('2018 - $mes - $dia'); $tabela3->data_nasc = $datatest; Quando faço debug para verificar o que vai ser gravado aparece da seguinte forma : "data_nasc" => "2018 - $12Europe/Lisbon30 - $1936pm" Link to comment Share on other sites More sharing options...
tiago.f Posted December 19, 2021 at 01:57 PM Report Share #624974 Posted December 19, 2021 at 01:57 PM (edited) Olá. sem saber o conteúdo das varas $mês e $dia é difícil. No entanto podes começar por trocar as plicas por aspas já que , com plicas , as variáveis não são avaliadas… Edited December 19, 2021 at 01:58 PM by tiago.f Link to comment Share on other sites More sharing options...
klasss Posted December 19, 2021 at 02:46 PM Author Report Share #624975 Posted December 19, 2021 at 02:46 PM (edited) $datatest= "2018-$mes-$dia"; Desta forma já aparece corretamente mas não grava na BD General error: 1364 Field 'created_at' doesn't have a default value (SQL: insert into `calendarios` (`title`, `start`, `end`) values (Becas, 2022-09-19, 2022-09-19) Edited December 19, 2021 at 03:01 PM by klasss Link to comment Share on other sites More sharing options...
M6 Posted December 20, 2021 at 08:32 AM Report Share #624983 Posted December 20, 2021 at 08:32 AM Tipocamente as BDs costumam aceitar datas no formato YYYY-MM-DD, e.g. 2018-12-20 o que tens nas variáveis não está nesse formato. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
tiago.f Posted December 20, 2021 at 08:49 AM Report Share #624984 Posted December 20, 2021 at 08:49 AM 18 hours ago, klasss said: $datatest= "2018-$mes-$dia"; Desta forma já aparece corretamente mas não grava na BD General error: 1364 Field 'created_at' doesn't have a default value (SQL: insert into `calendarios` (`title`, `start`, `end`) values (Becas, 2022-09-19, 2022-09-19) Como o erro diz: tens uma coluna “created_at” que não tem um valor default, logo tens que lhe passar um no insert… e neste momento só estás a passar title, start e end. Link to comment Share on other sites More sharing options...
pedrox Posted December 27, 2021 at 09:27 PM Report Share #625081 Posted December 27, 2021 at 09:27 PM Verifica se tens `public $timestamps = true;` no teu Model. A framework deve criar/actualizar esses campos automaticamente (se estiveres a usar Eloquent), se tiveres a fazer raw queries tens que definir manualmente esses campos. Outra coisa que ajuda é adicionares esses campos á propriedade publica `$dates` do model. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now