I am trying to create an entity programmatically.
My code:
//my entity
use \Drupal\my_module\Entity\my_entity;
$entity = my_entity::create(
[
'label' => "token",
'type' => "bundle",
'uuid' => $uuid,
'user_id' => $user->id(),
'entity_type' => $node->getType(),
'entity_id' => $node->id(),
'value' => 10,
'read' => false,
'created' => time(),
'changed' => time()
]
)->save();
However, on save, it gives me this sql error. What am I missing?
Drupal\Core\Entity\EntityStorageException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'read, created, changed) VALUES ('bundle', '4a6ca0e3-89f0-46da-8889-c42a7f45ec4a'' at line 1: INSERT INTO {my_table} (type, uuid, user_id, entity_type, entity_id, value, read, created, changed) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => bundle [:db_insert_placeholder_1] => 4a6ca0e3-89f0-46da-8889-c42a7f45ec4a [:db_insert_placeholder_2] => 2 [:db_insert_placeholder_3] => article [:db_insert_placeholder_4] => 14 [:db_insert_placeholder_5] => 10 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 1493818295 [:db_insert_placeholder_8] => 1493818295 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).