Skip to content

Commit 6515abf

Browse files
committed
Fix the botch
1 parent 79e177f commit 6515abf

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

user_guide_src/source/models/model.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,14 @@ insert()
314314
The first parametre is an associative array of data to create a new row of data in the database.
315315
If an object is passed instead of an array, it will attempt to convert it to an array.
316316

317-
The array's keys must match the name of the columns in the ```$table```, while the array's values are the values to save for that key:
317+
The array's keys must match the name of the columns in the ``$table``, while the array's values are the values to save for that key.
318318

319-
.. literalinclude:: model/015.php
319+
The optional second parameter is of type boolean, and if it is set to false, the method will return a boolean value,
320+
which indicates the success or failure of the query.
321+
322+
You can retrieve the last inserted row's primary key using the ``getInsertID()`` method.
320323

321-
The second parametre is of type boolean which determines whether an insert ID should be returned.
322-
If it is omitted, then the default return value is the insert id.
324+
.. literalinclude:: model/015.php
323325

324326
update()
325327
--------

user_guide_src/source/models/model/015.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@
55
'email' => 'd.vader@theempire.com',
66
];
77

8-
$userModel->insert($data, bool $returnID = true);
8+
// Inserts data and returns inserted row's primary key
9+
$userModel->insert($data);
10+
11+
// Inserts data and returns true on success and false on failure
12+
$userModel->insert($data, false);
13+
14+
// Returns inserted row's primary key
15+
$userModel->getInsertID();
16+

0 commit comments

Comments
 (0)