mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #5772 from kenjis/fix-docs-fix-empty-line
docs: add/remove empty line in sample code
This commit is contained in:
commit
970fa892b7
@ -10,5 +10,6 @@ class Services extends BaseService
|
||||
{
|
||||
return new \App\Router\MyRouter();
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Services extends BaseService
|
||||
{
|
||||
return new \CodeIgniter\View\View($viewPath);
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ class Services extends BaseService
|
||||
|
||||
return static::getSharedInstance('routes');
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -24,5 +24,6 @@ class Database extends Config
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
echo $db->table('my_table')->countAll();
|
||||
|
||||
// Produces an integer, like 25
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
echo $db->table('my_table')->like('title', 'match')->countAllResults();
|
||||
|
||||
// Produces an integer, like 5
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
$sql = $builder->getCompiledSelect();
|
||||
echo $sql;
|
||||
|
||||
// Prints string: SELECT * FROM mytable
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
$builder->select('title, content, date');
|
||||
$query = $builder->get();
|
||||
|
||||
// Executes: SELECT title, content, date FROM mytable
|
||||
|
@ -3,5 +3,4 @@
|
||||
$subquery = $db->table('users');
|
||||
$builder = $db->table('jobs')->fromSubquery($subquery, 'alias');
|
||||
$query = $builder->get();
|
||||
|
||||
// Produces: SELECT * FROM `jobs`, (SELECT * FROM `users`) AS `alias`
|
||||
|
@ -3,5 +3,4 @@
|
||||
$subquery = $db->table('users')->select('id, name');
|
||||
$builder = $db->newQuery()->fromSubquery($subquery, 't');
|
||||
$query = $builder->get();
|
||||
|
||||
// Produces: SELECT * FROM (SELECT `id`, `name` FROM users) AS `t`
|
||||
|
@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
// With closure
|
||||
|
||||
$builder->where('advance_amount <', function (BaseBuilder $builder) {
|
||||
return $builder->select('MAX(advance_amount)', false)->from('orders')->where('id >', 2);
|
||||
});
|
||||
|
||||
// Produces: WHERE "advance_amount" < (SELECT MAX(advance_amount) FROM "orders" WHERE "id" > 2)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->orWhereIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('job_id')->from('users_jobs')->where('user_id', 3);
|
||||
});
|
||||
|
||||
// Produces: OR "id" IN (SELECT "job_id" FROM "users_jobs" WHERE "user_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->whereNotIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('job_id')->from('users_jobs')->where('user_id', 3);
|
||||
});
|
||||
|
||||
// Produces: WHERE "id" NOT IN (SELECT "job_id" FROM "users_jobs" WHERE "user_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->orWhereNotIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('job_id')->from('users_jobs')->where('user_id', 3);
|
||||
});
|
||||
|
||||
// Produces: OR "id" NOT IN (SELECT "job_id" FROM "users_jobs" WHERE "user_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->orHavingIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('user_id')->from('users_jobs')->where('group_id', 3);
|
||||
});
|
||||
|
||||
// Produces: OR "id" IN (SELECT "user_id" FROM "users_jobs" WHERE "group_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->havingNotIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('user_id')->from('users_jobs')->where('group_id', 3);
|
||||
});
|
||||
|
||||
// Produces: HAVING "id" NOT IN (SELECT "user_id" FROM "users_jobs" WHERE "group_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -4,7 +4,6 @@
|
||||
$builder->orHavingNotIn('id', function (BaseBuilder $builder) {
|
||||
return $builder->select('user_id')->from('users_jobs')->where('group_id', 3);
|
||||
});
|
||||
|
||||
// Produces: OR "id" NOT IN (SELECT "user_id" FROM "users_jobs" WHERE "group_id" = 3)
|
||||
|
||||
// With builder directly
|
||||
|
@ -8,5 +8,4 @@ $data = [
|
||||
|
||||
$sql = $builder->set($data)->getCompiledInsert();
|
||||
echo $sql;
|
||||
|
||||
// Produces string: INSERT INTO mytable (`title`, `name`, `date`) VALUES ('My title', 'My name', 'My date')
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
echo $builder->set('title', 'My Title')->getCompiledInsert(false);
|
||||
|
||||
// Produces string: INSERT INTO mytable (`title`) VALUES ('My Title')
|
||||
|
||||
echo $builder->set('content', 'My Content')->getCompiledInsert();
|
||||
|
||||
// Produces string: INSERT INTO mytable (`title`, `content`) VALUES ('My Title', 'My Content')
|
||||
|
@ -7,5 +7,4 @@ $data = [
|
||||
];
|
||||
|
||||
$builder->replace($data);
|
||||
|
||||
// Executes: REPLACE INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')
|
||||
|
@ -3,5 +3,4 @@
|
||||
$subquery = $db->table('countries')->select('name')->where('id', 1);
|
||||
$builder = $db->table('users')->select('name')->selectSubquery($subquery, 'country');
|
||||
$query = $builder->get();
|
||||
|
||||
// Produces: SELECT `name`, (SELECT `name` FROM `countries` WHERE `id` = 1) AS `country` FROM `users`
|
||||
|
@ -14,5 +14,6 @@ class Services extends BaseService
|
||||
|
||||
return new \App\Libraries\RouteCollection(static::locator(), config('Modules'));
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ class MyConfig extends BaseConfig
|
||||
public static $registrars = [
|
||||
SupportingPackageRegistrar::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class Logger extends BaseConfig
|
||||
{
|
||||
public $threshold = 5;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ class Logger extends BaseConfig
|
||||
{
|
||||
// Log only debug and info type messages
|
||||
public $threshold = [5, 8];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Logger extends BaseConfig
|
||||
'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -5,5 +5,6 @@ namespace Config;
|
||||
class Paths
|
||||
{
|
||||
public $appDirectory = '/path/to/your/app';
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class Filters extends BaseConfig
|
||||
public $aliases = [
|
||||
'csrf' => \CodeIgniter\Filters\CSRF::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Filters extends BaseConfig
|
||||
\App\Filters\ApiAuth::class,
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Filters extends BaseConfig
|
||||
],
|
||||
'after' => [],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Filters extends BaseConfig
|
||||
],
|
||||
'after' => [],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Filters extends BaseConfig
|
||||
],
|
||||
'after' => [],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Filters extends BaseConfig
|
||||
'post' => ['foo', 'bar'],
|
||||
'get' => ['baz'],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Filters extends BaseConfig
|
||||
'foo' => ['before' => ['admin/*'], 'after' => ['users/*']],
|
||||
'bar' => ['before' => ['api/*', 'admin/*']],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Filters extends BaseConfig
|
||||
// ...
|
||||
'secureheaders' => \App\Filters\SecureHeaders::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class Cache extends BaseConfig
|
||||
{
|
||||
// ...
|
||||
|
||||
public $memcached = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'weight' => 1,
|
||||
'raw' => false,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ class Cache extends BaseConfig
|
||||
'timeout' => 0,
|
||||
'database' => 0,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class CURLRequest extends BaseConfig
|
||||
{
|
||||
public $shareOptions = false;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ class Encryption extends BaseConfig
|
||||
{
|
||||
// In Encryption, you may use
|
||||
public $key = 'hex2bin:<your-hex-encoded-key>';
|
||||
|
||||
// or
|
||||
public $key = 'base64:<your-base64-encoded-key>';
|
||||
// ...
|
||||
|
@ -16,5 +16,6 @@ class Filters extends BaseConfig
|
||||
'honeypot',
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Pager extends BaseConfig
|
||||
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ class Pager extends BaseConfig
|
||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||
'front_full' => 'App\Views\Pagers\foundation_full',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
public $csrfProtection = 'session';
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
public $tokenRandomize = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
public $regenerate = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ class Filters extends BaseConfig
|
||||
'csrf',
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ class Filters extends BaseConfig
|
||||
'csrf' => ['except' => ['api/record/save']],
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ class Filters extends BaseConfig
|
||||
'csrf' => ['except' => ['api/record/[0-9]+']],
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Filters extends BaseConfig
|
||||
'get' => ['csrf'],
|
||||
'post' => ['csrf'],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
$userData = $_SESSION;
|
||||
|
||||
// or:
|
||||
|
||||
$userData = $session->get();
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
unset($_SESSION['some_name']);
|
||||
|
||||
// or multiple values:
|
||||
|
||||
unset(
|
||||
$_SESSION['some_name'],
|
||||
$_SESSION['another_name']
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
session_destroy();
|
||||
|
||||
// or
|
||||
|
||||
$session->destroy();
|
||||
|
@ -9,5 +9,6 @@ class App extends BaseConfig
|
||||
// localhost will be given higher priority (5) here,
|
||||
// compared to 192.0.2.1 with a weight of 1.
|
||||
public $sessionSavePath = 'localhost:11211:5,192.0.2.1:11211:1';
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Filters extends BaseConfig
|
||||
// ...
|
||||
'throttle' => \App\Filters\Throttle::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class Filters extends BaseConfig
|
||||
public $methods = [
|
||||
'post' => ['throttle'],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Validation
|
||||
\CodeIgniter\Validation\StrictRules\FormatRules::class,
|
||||
\CodeIgniter\Validation\StrictRules\Rules::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Validation
|
||||
'pass_confirm' => 'required|matches[password]',
|
||||
'email' => 'required|valid_email',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ class Validation
|
||||
'pass_confirm' => 'required|matches[password]',
|
||||
'email' => 'required|valid_email',
|
||||
];
|
||||
|
||||
public $signup_errors = [
|
||||
'username' => [
|
||||
'required' => 'You must choose a username.',
|
||||
@ -18,5 +19,6 @@ class Validation
|
||||
'valid_email' => 'Please check the Email field. It does not appear to be valid.',
|
||||
],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class Validation
|
||||
'single' => 'CodeIgniter\Validation\Views\single',
|
||||
'my_list' => '_errors_list',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ class Validation
|
||||
FileRules::class,
|
||||
CreditCardRules::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Format extends BaseConfig
|
||||
'application/json',
|
||||
'application/xml',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ class Format extends BaseConfig
|
||||
'application/json' => \CodeIgniter\Format\JSONFormatter::class,
|
||||
'application/xml' => \CodeIgniter\Format\XMLFormatter::class,
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class App extends BaseConfig
|
||||
{
|
||||
public $defaultLocale = 'en';
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class App extends BaseConfig
|
||||
{
|
||||
public $negotiateLocale = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class App extends BaseConfig
|
||||
{
|
||||
public $supportedLocales = ['en', 'es', 'fr-FR'];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ use CodeIgniter\Config\BaseConfig;
|
||||
class App extends BaseConfig
|
||||
{
|
||||
public $CSPEnabled = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class View extends BaseView
|
||||
public array $decorators = [
|
||||
'App\Views\Decorators\MyDecorator',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -4,5 +4,4 @@ $template = '<head><title>{blog_title}</title></head>';
|
||||
$data = ['blog_title' => 'My ramblings'];
|
||||
|
||||
echo $parser->setData($data)->renderString($template);
|
||||
|
||||
// Result: <head><title>My ramblings</title></head>
|
||||
|
@ -10,5 +10,6 @@ class View extends BaseView
|
||||
'abs' => '\CodeIgniter\View\Filters::abs',
|
||||
'capitalize' => '\CodeIgniter\View\Filters::capitalize',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class View extends BaseView
|
||||
public $filters = [
|
||||
'str_repeat' => '\str_repeat',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ class View extends BaseView
|
||||
public $plugins = [
|
||||
'foo' => '\Some\Class::methodName',
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -16,5 +16,6 @@ class View extends BaseView
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ class View extends BaseView
|
||||
public $plugins = [
|
||||
'foo' => ['\Some\Class::methodName'],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
@ -8,5 +8,4 @@ $data = [
|
||||
];
|
||||
echo $parser->setData($data)
|
||||
->renderString($template);
|
||||
|
||||
// Result: Hello, John Doe
|
||||
|
@ -8,5 +8,4 @@ $data = [
|
||||
];
|
||||
echo $parser->setData($data)
|
||||
->renderString($template);
|
||||
|
||||
// Result: Hello, John {initials} Doe
|
||||
|
@ -12,5 +12,4 @@ $data = [
|
||||
];
|
||||
echo $parser->setData($data)
|
||||
->renderString($template);
|
||||
|
||||
// Result: Hello, John Doe (Mr{degree} {/degrees})
|
||||
|
@ -15,5 +15,6 @@ final class FilterTestCase extends CIUnitTestCase
|
||||
|
||||
$this->assertHasFilters('unfiltered/route', 'before');
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ trait AuthTrait
|
||||
$user = $this->createFakeUser();
|
||||
$this->logInUser($user);
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
@ -9,5 +9,6 @@ class Filters extends BaseConfig
|
||||
public $methods = [
|
||||
'post' => ['csrf'],
|
||||
];
|
||||
|
||||
// ...
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user