PHP code example of mr-jiawen / php-database-repository

1. Go to this page and download the library: Download mr-jiawen/php-database-repository library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mr-jiawen / php-database-repository example snippets


composer 

    php artisan vendor:publish
  

    自动构建的代码的树形结构:
    - app/        #项目的app根目录
       - Model/       #model模型目录-> 每一个表一个模型
         - Cache/         #model 的缓存目录,对每个表的代码构建全部存放在此目录下(这里的代码是实时刷新的)
           - DatabaseCacheModel.php         
         - DatabaseModel.php    #model的入口文件(所有的自定义方法全部放在此处)
      - Store/         #store数据仓库目录,每个数据厂库存放处
        - Cache/          #repository的缓存目录,每个数据仓库自动构建的代码存放在此目录下(这里的代码是实时刷新额)
           - DatabaseCacheStore.php
        - DatabaseStore.php      #repository的入口文件(所有的自定义方法全部放在此处)
  

public function getOfTel($where, $field = null)
{
    return parent::get($where, $field, function ($db) {
        return $db->orderBy('add_time', 'DSC');
    });
}