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_models.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
@@ -24,15 +24,15 @@ Upgrade Guide
24
24
2. Add this line just after the opening php tag: ``namespace App\Models;``.
25
25
3. Below the ``namespace App\Models;`` line add this line: ``use CodeIgniter\Model;``.
26
26
4. Replace ``extends CI_Model`` with ``extends Model``.
27
-
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 :php:func:`model()` function: ``$this->x = model('X');``.
27
+
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 :php:func:`model()` function: ``$this->x = model('X');``.
28
28
29
29
If you use sub-directories in your model structure you have to change the namespace according to that.
30
30
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
31
32
32
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``.
33
33
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.
34
34
35
-
You can find more information to those methods :doc:`here </models/model>`.
35
+
You can find more information to those methods in :doc:`../models/model`.
0 commit comments