Skip to content

Commit 4d74a57

Browse files
committed
Add return types in user guide comments
1 parent 9c35bcd commit 4d74a57

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

guide/index.rst

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ the SQL statement:
146146
.. code-block:: php
147147
148148
$name = $database->quote($_POST['name']);
149-
$affectedRows = $database->exec('INSERT INTO Users SET name = ' $name); // int
149+
$affectedRows = $database->exec(
150+
'INSERT INTO Users SET name = ' . $name
151+
); // int or string
150152
151153
Prepared Statement
152154
##################
@@ -183,7 +185,7 @@ class, passing the values in order in the same way as in the ``query`` method:
183185
.. code-block:: php
184186
185187
$affectedRows = $database->prepare('INSERT INTO Users SET name = ?')
186-
->exec($_POST['name']); // int
188+
->exec($_POST['name']); // int or string
187189
188190
Result
189191
######
@@ -275,7 +277,7 @@ You can insert a row only using the SET clause:
275277
->set([
276278
'name' => 'John',
277279
'email' => 'foo@baz.com',
278-
])->run();
280+
])->run(); // int or string
279281
280282
.. code-block:: sql
281283
@@ -293,7 +295,7 @@ Or several at once using the ``columns`` and ``values`` methods:
293295
->values([
294296
['John', 'foo@baz.com'],
295297
['Mary', 'bar@baz.com'],
296-
])->run();
298+
])->run(); // int or string
297299
298300
SQL executed:
299301

@@ -314,7 +316,7 @@ Database class.
314316

315317
.. code-block:: php
316318
317-
$id = $database->insertId();
319+
$id = $database->insertId(); // int or string
318320
319321
When several rows are inserted in the same statement, the id returned is that of
320322
the first inserted row.
@@ -333,7 +335,7 @@ is equal to one.
333335
->table('Users')
334336
->set(['name' => 'Johnny']);
335337
->whereEqual('id', 1)
336-
->run();
338+
->run(); // int or string
337339
338340
The SQL statement executed above is the same as below:
339341

@@ -357,7 +359,7 @@ equal to 88:
357359
$affectedRows = $database->delete()
358360
->from('Users')
359361
->whereEqual('id', 88)
360-
->run();
362+
->run(); // int or string
361363
362364
The example above builds and executes the following SQL statement:
363365

@@ -382,7 +384,7 @@ Let's see an example replacing a row in the Users table:
382384
->into('Users')
383385
->columns('id', 'name', 'email')
384386
->values(1, 'John Doe', 'johndoe@ecorp.tld')
385-
->run();
387+
->run(); // int or string
386388
387389
The SQL statement below is the one executed in the example above:
388390

@@ -405,14 +407,14 @@ having a temporary table that only exists for the duration of a query.
405407
return $select->expressions('a')
406408
->from('t1')
407409
->whereGreaterThanOrEqual('b', 'c')
408-
->sql();
410+
->sql(); // string
409411
})->select(function (Select $select) {
410412
return $select->from('t2', 't')
411413
->whereEqual(
412414
't2.c',
413415
fn (Database $db) => $db->protectIdentifier('t.a')
414-
)->sql();
415-
})->run();
416+
)->sql(); // string
417+
})->run(); // Result
416418
417419
The code above will build and execute the following statement:
418420

@@ -446,7 +448,7 @@ Let's see an example below:
446448
->intoTable('Users')
447449
->charset('utf8')
448450
->columnsTerminatedBy(',')
449-
->run();
451+
->run(); // int or string
450452
451453
Will run the following statement:
452454

@@ -490,7 +492,7 @@ Let's look at an example creating the ``app`` schema:
490492

491493
.. code-block:: php
492494
493-
$database->createSchema('app')->run();
495+
$database->createSchema('app')->run(); // int or string
494496
495497
The statement executed above is the same as the example below:
496498

@@ -507,7 +509,7 @@ Let's see, in the example below, how to change the charset of the app schema:
507509

508510
.. code-block:: php
509511
510-
$database->alterSchema('app')->charset('utf8')->run();
512+
$database->alterSchema('app')->charset('utf8')->run(); // int or string
511513
512514
.. code-block:: sql
513515
@@ -523,7 +525,7 @@ Let's see how to remove the app schema:
523525

524526
.. code-block:: php
525527
526-
$database->dropSchema('app')->run();
528+
$database->dropSchema('app')->run(); // int or string
527529
528530
.. code-block:: sql
529531
@@ -551,7 +553,7 @@ columns and indexes in it:
551553
->default('basic')
552554
->comment('User type used in the authorization system');
553555
$def->index()->uniqueKey('email');
554-
})->run();
556+
})->run(); // int or string
555557
556558
The PHP example above will build and execute the following SQL:
557559

@@ -582,7 +584,7 @@ Users table:
582584
->add(function (TableDefinition $def) {
583585
$def->column('configs')->json()->default('{}');
584586
$def->column('birthday')->date()->null()->after('name');
585-
})->run();
587+
})->run(); // int or string
586588
587589
The code above will build and execute the following statement:
588590

@@ -599,7 +601,7 @@ DROP TABLE removes one or more tables from a database schema:
599601

600602
.. code-block:: php
601603
602-
$database->dropTable('Users')->run();
604+
$database->dropTable('Users')->run(); // int or string
603605
604606
.. code-block:: sql
605607

0 commit comments

Comments
 (0)