Based on the information in the comments I'll provide an example how to save elements in Craft. I'll just show an example with an existing element type Entry. You can see how to create a custom element type well documented in the docs
You'll create a new section in your CP and add the required fields to the layout. In your case you'll need title (Booktitle), author (BookAuthor), summary (BookSummary) and pages (Pages)
// get the section and the entrytype
// when you know your section id and entrytype id you don't
// need this. You can get the Ids by looking at the URL in the
// when you edit them
$section = Craft::$app->sections->getSectionByHandle('books');
$entryType = reset($section->getEntryTypes());
// Create an entry
$entry = new Entry([
'sectionId' => $section->id,
'typeId' => $entryType->id, // or insert the required type id manually
'fieldLayoutId' => $entryType->fieldLayoutId,
'authorId' => 1,
'title' => 'A cool title of a book',
'slug' => 'a-cool-title-of-a-book', // <- not required
]);
$entry->setFieldValues([
'author' => 'Me and Myself',
'summary' => 'it was awesome',
'pages' => 9000
]);
// Save the entry
Craft::$app->elements->saveElement($entry);
// in case there is something wrong..
$errors = $entry->getErrors();
When you are going to create your custom element type without a field layout your code could look like this
$book = new Book([
'title' => 'A cool title of a book',
'author' => 'Me and Myself',
'summary' => 'it was awesome',
'pages' => 9000
]);
// Save the entry
Craft::$app->elements->saveElement($book);
// in case there is something wrong..
$errors = $book->getErrors();
recordsorelementsto store your data. I'll show you the code depending on your choice/needs https://craftcms.stackexchange.com/questions/23859/database-structure-for-craft-3-to-import-from-external-source/23863#23863 – Robin Schambach Apr 03 '18 at 19:18