Skip to content

Commit ffcf115

Browse files
authored
Update documentation code samples (#5039)
1 parent a630617 commit ffcf115

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+762
-922
lines changed

env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
2727
# app.sessionCookieName = 'ci_session'
2828
# app.sessionExpiration = 7200
29-
# app.sessionSavePath = NULL
29+
# app.sessionSavePath = null
3030
# app.sessionMatchIP = false
3131
# app.sessionTimeToUpdate = 300
3232
# app.sessionRegenerateDestroy = false

user_guide_src/source/cli/cli_commands.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,9 @@ be familiar with when creating your own commands. It also has a :doc:`Logger </g
187187

188188
A convenience method to maintain a consistent and clear error output to the CLI::
189189

190-
try
191-
{
190+
try {
192191
. . .
193-
}
194-
catch (\Exception $e)
195-
{
192+
} catch (\Exception $e) {
196193
$this->showError($e);
197194
}
198195

@@ -208,8 +205,8 @@ be familiar with when creating your own commands. It also has a :doc:`Logger </g
208205
A method to calculate padding for $key => $value array output. The padding can be used to output a will formatted table in CLI::
209206

210207
$pad = $this->getPad($this->options, 6);
211-
foreach ($this->options as $option => $description)
212-
{
208+
209+
foreach ($this->options as $option => $description) {
213210
CLI::write($tab . CLI::color(str_pad($option, $pad), 'green') . $description, 'yellow');
214211
}
215212

user_guide_src/source/cli/cli_library.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ Instead it prints it to the screen wherever the cursor is currently. This allows
119119
the same line, from different calls. This is especially helpful when you want to show a status, do something, then
120120
print "Done" on the same line::
121121

122-
for ($i = 0; $i <= 10; $i++)
123-
{
122+
for ($i = 0; $i <= 10; $i++) {
124123
CLI::print($i);
125124
}
126125

@@ -172,8 +171,7 @@ every line after the first line, so that you will have a crisp column edge on th
172171
// to determine the width of the left column
173172
$maxlen = max(array_map('strlen', $titles));
174173

175-
for ($i=0; $i < count($titles); $i++)
176-
{
174+
for ($i = 0; $i < count($titles); $i++) {
177175
CLI::write(
178176
// Display the title on the left of the row
179177
$titles[$i] . ' ' .
@@ -227,8 +225,7 @@ pass ``false`` as the first parameter and the progress bar will be removed.
227225
$totalSteps = count($tasks);
228226
$currStep = 1;
229227

230-
foreach ($tasks as $task)
231-
{
228+
foreach ($tasks as $task) {
232229
CLI::showProgress($currStep++, $totalSteps);
233230
$task->run();
234231
}

user_guide_src/source/cli/cli_request.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Returns the value of a specific command line argument deemed to be an option::
3737

3838
// command line: php index.php users 21 profile --foo bar
3939
echo $request->getOption('foo'); // bar
40-
echo $request->getOption('notthere'); // NULL
40+
echo $request->getOption('notthere'); // null
4141

4242
**getOptionString()**
4343

user_guide_src/source/database/configuration.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ prototype::
2222
'database' => 'database_name',
2323
'DBDriver' => 'MySQLi',
2424
'DBPrefix' => '',
25-
'pConnect' => TRUE,
26-
'DBDebug' => TRUE,
25+
'pConnect' => true,
26+
'DBDebug' => true,
2727
'charset' => 'utf8',
2828
'DBCollat' => 'utf8_general_ci',
2929
'swapPre' => '',
30-
'encrypt' => FALSE,
31-
'compress' => FALSE,
32-
'strictOn' => FALSE,
30+
'encrypt' => false,
31+
'compress' => false,
32+
'strictOn' => false,
3333
'failover' => [],
3434
];
3535

@@ -80,14 +80,14 @@ These failovers can be specified by setting the failover for a connection like t
8080
'database' => '',
8181
'DBDriver' => 'MySQLi',
8282
'DBPrefix' => '',
83-
'pConnect' => TRUE,
84-
'DBDebug' => TRUE,
83+
'pConnect' => true,
84+
'DBDebug' => true,
8585
'charset' => 'utf8',
8686
'DBCollat' => 'utf8_general_ci',
8787
'swapPre' => '',
88-
'encrypt' => FALSE,
89-
'compress' => FALSE,
90-
'strictOn' => FALSE
88+
'encrypt' => false,
89+
'compress' => false,
90+
'strictOn' => false,
9191
],
9292
[
9393
'hostname' => 'localhost2',
@@ -96,14 +96,14 @@ These failovers can be specified by setting the failover for a connection like t
9696
'database' => '',
9797
'DBDriver' => 'MySQLi',
9898
'DBPrefix' => '',
99-
'pConnect' => TRUE,
100-
'DBDebug' => TRUE,
99+
'pConnect' => true,
100+
'DBDebug' => true,
101101
'charset' => 'utf8',
102102
'DBCollat' => 'utf8_general_ci',
103103
'swapPre' => '',
104-
'encrypt' => FALSE,
105-
'compress' => FALSE,
106-
'strictOn' => FALSE
104+
'encrypt' => false,
105+
'compress' => false,
106+
'strictOn' => false,
107107
]
108108
];
109109

@@ -123,14 +123,14 @@ example, to set up a "test" environment you would do this::
123123
'database' => 'database_name',
124124
'DBDriver' => 'MySQLi',
125125
'DBPrefix' => '',
126-
'pConnect' => TRUE,
127-
'DBDebug' => TRUE,
126+
'pConnect' => true,
127+
'DBDebug' => true,
128128
'charset' => 'utf8',
129129
'DBCollat' => 'utf8_general_ci',
130130
'swapPre' => '',
131-
'compress' => FALSE,
132-
'encrypt' => FALSE,
133-
'strictOn' => FALSE,
131+
'compress' => false,
132+
'encrypt' => false,
133+
'strictOn' => false,
134134
'failover' => []
135135
);
136136

@@ -188,8 +188,8 @@ Explanation of Values:
188188
**DBPrefix** An optional table prefix which will added to the table name when running
189189
:doc:`Query Builder <query_builder>` queries. This permits multiple CodeIgniter
190190
installations to share one database.
191-
**pConnect** TRUE/FALSE (boolean) - Whether to use a persistent connection.
192-
**DBDebug** TRUE/FALSE (boolean) - Whether database errors should be displayed.
191+
**pConnect** true/false (boolean) - Whether to use a persistent connection.
192+
**DBDebug** true/false (boolean) - Whether database errors should be displayed.
193193
**charset** The character set used in communicating with the database.
194194
**DBCollat** The character collation used in communicating with the database
195195

@@ -201,18 +201,18 @@ Explanation of Values:
201201
**schema** The database schema, default value varies by driver. Used by PostgreSQL and SQLSRV drivers.
202202
**encrypt** Whether or not to use an encrypted connection.
203203

204-
- 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
204+
- 'sqlsrv' and 'pdo/sqlsrv' drivers accept true/false
205205
- 'MySQLi' and 'pdo/mysql' drivers accept an array with the following options:
206206

207207
- 'ssl_key' - Path to the private key file
208208
- 'ssl_cert' - Path to the public key certificate file
209209
- 'ssl_ca' - Path to the certificate authority file
210210
- 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
211211
- 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
212-
- 'ssl_verify' - TRUE/FALSE; Whether to verify the server certificate or not ('MySQLi' only)
212+
- 'ssl_verify' - true/false; Whether to verify the server certificate or not ('MySQLi' only)
213213

214214
**compress** Whether or not to use client compression (MySQL only).
215-
**strictOn** TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
215+
**strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
216216
while developing an application.
217217
**port** The database port number. To use this value you have to add a line to the database config array.
218218
::

user_guide_src/source/database/connecting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Available Parameters
2727
--------------------
2828

2929
#. The database group name, a string that must match the config class' property name. Default value is ``$config->defaultGroup``.
30-
#. TRUE/FALSE (boolean). Whether to return the shared connection (see
30+
#. true/false (boolean). Whether to return the shared connection (see
3131
Connecting to Multiple Databases below).
3232

3333
Manually Connecting to a Database

user_guide_src/source/database/examples.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ Standard Query With Multiple Results (Object Version)
2828

2929
::
3030

31-
$query = $db->query('SELECT name, title, email FROM my_table');
31+
$query = $db->query('SELECT name, title, email FROM my_table');
3232
$results = $query->getResult();
3333

34-
foreach ($results as $row)
35-
{
34+
foreach ($results as $row) {
3635
echo $row->title;
3736
echo $row->name;
3837
echo $row->email;
@@ -51,8 +50,7 @@ Standard Query With Multiple Results (Array Version)
5150
$query = $db->query('SELECT name, title, email FROM my_table');
5251
$results = $query->getResultArray();
5352

54-
foreach ($results as $row)
55-
{
53+
foreach ($results as $row) {
5654
echo $row['title'];
5755
echo $row['name'];
5856
echo $row['email'];
@@ -102,8 +100,7 @@ means of retrieving data::
102100

103101
$query = $db->table('table_name')->get();
104102

105-
foreach ($query->getResult() as $row)
106-
{
103+
foreach ($query->getResult() as $row) {
107104
echo $row->title;
108105
}
109106

@@ -124,4 +121,3 @@ Query Builder Insert
124121

125122
$db->table('mytable')->insert($data);
126123
// Produces: INSERT INTO mytable (title, name, date) VALUES ('{$title}', '{$name}', '{$date}')
127-

user_guide_src/source/database/metadata.rst

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ you are currently connected to. Example::
2222

2323
$tables = $db->listTables();
2424

25-
foreach ($tables as $table)
26-
{
25+
foreach ($tables as $table) {
2726
echo $table;
2827
}
2928

@@ -35,10 +34,9 @@ Determine If a Table Exists
3534
**$db->tableExists();**
3635

3736
Sometimes it's helpful to know whether a particular table exists before
38-
running an operation on it. Returns a boolean TRUE/FALSE. Usage example::
37+
running an operation on it. Returns a boolean true/false. Usage example::
3938

40-
if ($db->tableExists('table_name'))
41-
{
39+
if ($db->tableExists('table_name')) {
4240
// some code...
4341
}
4442

@@ -60,8 +58,7 @@ two ways:
6058

6159
$fields = $db->getFieldNames('table_name');
6260

63-
foreach ($fields as $field)
64-
{
61+
foreach ($fields as $field) {
6562
echo $field;
6663
}
6764

@@ -70,8 +67,7 @@ calling the function from your query result object::
7067

7168
$query = $db->query('SELECT * FROM some_table');
7269

73-
foreach ($query->getFieldNames() as $field)
74-
{
70+
foreach ($query->getFieldNames() as $field) {
7571
echo $field;
7672
}
7773

@@ -81,10 +77,9 @@ Determine If a Field is Present in a Table
8177
**$db->fieldExists()**
8278

8379
Sometimes it's helpful to know whether a particular field exists before
84-
performing an action. Returns a boolean TRUE/FALSE. Usage example::
80+
performing an action. Returns a boolean true/false. Usage example::
8581

86-
if ($db->fieldExists('field_name', 'table_name'))
87-
{
82+
if ($db->fieldExists('field_name', 'table_name')) {
8883
// some code...
8984
}
9085

@@ -108,8 +103,7 @@ Usage example::
108103

109104
$fields = $db->getFieldData('table_name');
110105

111-
foreach ($fields as $field)
112-
{
106+
foreach ($fields as $field) {
113107
echo $field->name;
114108
echo $field->type;
115109
echo $field->max_length;
@@ -141,11 +135,10 @@ Usage example::
141135

142136
$keys = $db->getIndexData('table_name');
143137

144-
foreach ($keys as $key)
145-
{
146-
echo $key->name;
147-
echo $key->type;
148-
echo $key->fields; // array of field names
138+
foreach ($keys as $key) {
139+
echo $key->name;
140+
echo $key->type;
141+
echo $key->fields; // array of field names
149142
}
150143

151144
The key types may be unique to the database you are using.
@@ -160,8 +153,7 @@ Usage example::
160153

161154
$keys = $db->getForeignKeyData('table_name');
162155

163-
foreach ($keys as $key)
164-
{
156+
foreach ($keys as $key) {
165157
echo $key->constraint_name;
166158
echo $key->table_name;
167159
echo $key->column_name;

0 commit comments

Comments
 (0)