You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_database.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ What has been changed
20
20
21
21
Upgrade Guide
22
22
=============
23
-
1. Add your database credentials to ``app/Config/Database.php``. The options are pretty much the same as in CI3 only some names have changed slightly.
23
+
1. Add your database credentials to **app/Config/Database.php**. The options are pretty much the same as in CI3 only some names have changed slightly.
24
24
2. Everywhere you have used the database you have to replace ``$this->load->database();`` with ``$db = db_connect();``.
25
25
3. If you use multiple databases use the following code to load additional databases ``$db = db_connect('group_name');``.
26
26
4. Now you have to change all database queries. The most important change here is to replace ``$this->db`` with just ``$db`` and adjust the method name and ``$db``. Here are some examples:
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_encryption.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ What has been changed
19
19
20
20
Upgrade Guide
21
21
=============
22
-
1. Within your configs the ``$config['encryption_key'] = 'abc123';`` moved from ``application/config/config.php`` to ``public $key = 'abc123';`` in ``app/Config/Encryption.php``.
22
+
1. Within your configs the ``$config['encryption_key'] = 'abc123';`` moved from **application/config/config.php** to ``public $key = 'abc123';`` in **app/Config/Encryption.php**.
23
23
2. Wherever you have used the encryption library you have to replace ``$this->load->library('encryption');`` with ``$encrypter = service('encrypter');`` and change the methods for encryption and decrypting like in the following code example.
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_file_upload.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ What has been changed
18
18
Upgrade Guide
19
19
=============
20
20
In CI4 you access uploaded files with ``$file = $this->request->getFile('userfile')``. From there you can validate if the file got uploaded successfully with ``$file->isValid()``.
21
-
To store the file you could use ``$path = $this->request->getFile('userfile')->store('head_img/', 'user_name.jpg');`` This will store the file in ``writable/uploads/head_img/user_name.jpg``.
21
+
To store the file you could use ``$path = $this->request->getFile('userfile')->store('head_img/', 'user_name.jpg');``. This will store the file in **writable/uploads/head_img/user_name.jpg**.
22
22
23
23
You have to change your file uploading code to match the new methods.
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_localization.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,11 @@ What has been changed
19
19
20
20
Upgrade Guide
21
21
=============
22
-
1. Specify the default language in *Config/App.php*:::
22
+
1. Specify the default language in **Config/App.php**::
23
23
24
24
public $defaultLocale = 'en';
25
25
26
-
2. Now move your language files to ``app/Language/<locale>/``.
26
+
2. Now move your language files to **app/Language/<locale>**.
27
27
3. After that you have to change the syntax within the language files. Below in the Code Example you will see how the language array within the file should look like.
28
28
4. Remove from every file the language loader ``$this->lang->load($file, $lang);``.
29
29
5. Replace the method to load the language line ``$this->lang->line('error_email_missing')`` with ``echo lang('Errors.errorEmailMissing');``.
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_models.rst
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,14 +21,14 @@ What has been changed
21
21
Upgrade Guide
22
22
=============
23
23
24
-
1. First, move all model files to the folder ``app/Models``.
24
+
1. First, move all model files to the folder **app/Models**.
25
25
2. Add this line just after the opening php tag: ``namespace App\Models;``.
26
26
3. Below the ``namespace App\Models;`` line add this line: ``use CodeIgniter\Model;``.
27
27
4. Replace ``extends CI_Model`` with ``extends Model``.
28
-
5. Instead of CI3’s ``$this->load->model(x);``, you would now use ``$this->x = new X();``, following namespaced conventions for your component. Alternatively, you can use the ``model`` function: ``$this->x = model('X');``.
28
+
5. Instead of CI3’s ``$this->load->model(x);``, you would now use ``$this->x = new X();``, following namespaced conventions for your component. Alternatively, you can use the ``model()`` function: ``$this->x = model('X');``.
29
29
30
30
If you use sub-directories in your model structure you have to change the namespace according to that.
31
-
Example: You have a version 3 model located in ``application/models/users/user_contact.php`` the namespace has to be ``namespace App\Models\Users;`` and the model path in the version 4 should look like this: ``app/Models/Users/UserContact.php``
31
+
Example: You have a version 3 model located in **application/models/users/user_contact.php** the namespace has to be ``namespace App\Models\Users;`` and the model path in the version 4 should look like this: **app/Models/Users/UserContact.php**
32
32
33
33
The new Model in CI4 has a lot of built-in methods. For example, the ``find($id)`` method. With this you can find data where the primary key is equal to ``$id``.
34
34
Inserting data is also easier than before. In CI4 there is an ``insert($data)`` method. You can optionally make use of all those built-in methods and migrate your code to the new methods.
@@ -41,7 +41,7 @@ Code Example
41
41
CodeIgniter Version 3.11
42
42
------------------------
43
43
44
-
Path: ``application/models``::
44
+
Path: **application/models**::
45
45
46
46
<?php
47
47
@@ -60,7 +60,7 @@ Path: ``application/models``::
60
60
CodeIgniter Version 4.x
61
61
-----------------------
62
62
63
-
Path: ``app/Models``::
63
+
Path: **app/Models**::
64
64
65
65
<?php
66
66
@@ -73,4 +73,4 @@ Path: ``app/Models``::
73
73
// insert() method already implemented in parent
74
74
}
75
75
76
-
To insert data you can just directly call the ``$model->insert()`` method because this method is built-in since CI 4.
76
+
To insert data you can just directly call the ``$model->insert()`` method because this method is built-in since CI4.
0 commit comments