Skip to content

Commit 62c560b

Browse files
authored
Merge pull request #6660 from domaingenerator/modify-insert-method-details
Modify the user guide of the insert() method to include the second parameter
2 parents f6a0343 + caebceb commit 62c560b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

user_guide_src/source/models/model.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,18 @@ Saving Data
311311
insert()
312312
--------
313313

314-
An associative array of data is passed into this method as the only parameter to create a new
315-
row of data in the database. The array's keys must match the name of the columns in a ``$table``, while
316-
the array's values are the values to save for that key:
314+
The first parametre is an associative array of data to create a new row of data in the database.
315+
If an object is passed instead of an array, it will attempt to convert it to an array.
317316

318-
.. literalinclude:: model/015.php
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.
318+
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.
319321

320322
You can retrieve the last inserted row's primary key using the ``getInsertID()`` method.
321323

324+
.. literalinclude:: model/015.php
325+
322326
update()
323327
--------
324328

user_guide_src/source/models/model/015.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55
'email' => '[email protected]',
66
];
77

8+
// Inserts data and returns inserted row's primary key
89
$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();

0 commit comments

Comments
 (0)