It is provided for developers to use. It is useless for ordinary users to download unless the plug-in or theme is required.
I believe that there are friends who use laravel and know how comfortable ORM is to use it. Now it's coming!!!
Need to prepare:
php >= 7.3
Configure composer
Familiar with namespace and autoloading
It can be used after installation. Examples are as follows:
1. Create a new composer under any directory in the theme or plug-in JSON file, write the following code:
{
"autoload": {
"psr-4": {
"ModelsDemo\\": "./ModelsDemo",
"ObserverDemo\\": "./ObserverDemo"
}
}
}
Note: in order to avoid conflicts between the name of the theme or the name of the plug-in, you need to automatically load the folder with the name of the plug-in
2. Execute composer dump autoload to configure automatic loading
3. Include in the theme or plug-in Autoload is introduced into PHP PHP, such as:
include_ once dirname(__FILE__) . DIRECTORY_ SEPARATOR.'/ vendor/autoload. php';
Please refer to Larravel ORM documentation , does not support facade class. For transaction related, please refer to the methods of models / basemodel in the plug-in. Other operations remain unchanged.
Code cloud address: https://gitee.com/SongHaiFeng/Zblog-Eloquent-ORM
#Updated on May 17, 2022
Adjust a problem of last update
The default database link is used to adjust the system table by default
#Updated on April 16, 2022
Add the custompaginate method for paging
#Updated on November 24, 2021
Code conversion table support
Support configuration of multiple databases
#Updated on May 11, 2021
Add pagination support. Examples are as follows:
$post = \Models\Post::query()->paginate(10, ['*'], 'p', GetVars('p', 'GET', 1));
echo \Base\Pagination::paginate($post);
Here, it returns the paged HTML structure conforming to bootstrap. If NULL is returned, there will be no paging.
In addition, the pagename of the pagenate method is page by default, and the default paging parameter of zblog is also page, so you need to specify that the paging parameter is p and must be P.