Skip to content

Commit 192c5b2

Browse files
committed
docs: improve $builder->insert() description
1 parent 4bbc13c commit 192c5b2

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

user_guide_src/source/database/query_builder.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,17 @@ method. Here is an example using an array:
829829

830830
The first parameter is an associative array of values.
831831

832+
.. note:: All values except ``RawSql`` are escaped automatically producing safer queries.
833+
834+
.. warning:: When you use ``RawSql``, you MUST escape the data manually. Failure to do so could result in SQL injections.
835+
832836
Here is an example using an object:
833837

834838
.. literalinclude:: query_builder/077.php
835839

836-
The first parameter is an object.
840+
.. literalinclude:: query_builder/121.php
837841

838-
.. note:: All values except ``RawSql`` are escaped automatically producing safer queries.
839-
840-
.. warning:: When you use ``RawSql``, you MUST escape the data manually. Failure to do so could result in SQL injections.
842+
The first parameter is an object.
841843

842844
$builder->ignore()
843845
------------------

user_guide_src/source/database/query_builder/077.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
namespace App\Libraries;
44

5-
class Myclass
5+
class MyClass
66
{
77
public $title = 'My Title';
88
public $content = 'My Content';
99
public $date = 'My Date';
1010
}
11-
12-
$object = new Myclass();
13-
$builder->insert($object);
14-
// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
use App\Libraries\MyClass;
4+
5+
$object = new MyClass();
6+
$builder->insert($object);
7+
// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')

0 commit comments

Comments
 (0)