Previously at Joomla 3 this is possible to do something like-
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->insert($db->qn('#__myTable'));
$query->columns([$db->qn('title'), $db->qn('text')]);
$query->values($db->q('hello world') . ', ' . $db->q('This is the world'));
$db->setQuery($query);
$db->execute();
But now at Joomla 4, this is not working. It says
Field 'asset_id' doesn't have a default value.
So the question is the $db
should generate the asset_id
and if I am wrong then what is the solution for inserting values for only a few columns?
Labels |
Added:
?
|
MySQL drivers in 4.0 use STRICT_TRANS_TABLES
mode. You either have to modify the column to add the default value or pass the value when inserting data.
MySQL drivers in 4.0 use
STRICT_TRANS_TABLES
mode. You either have to modify the column to add the default value or pass the value when inserting data.
Does that mean there are no other alternatives?
Does that mean there are no other alternatives?
No, you just need to fix your table (if the column should allow empty inserts) or fix you code to always send the value. Which both is quite easy to do.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-10-14 05:49:27 |
Closed_By | ⇒ | ahamed |
Thanks to everyone. I get the solution.
Since?
#__myTable
isn't a core table you would have to know yourself what you messed up there