PHP code example of fanqingxuan / gen-models

1. Go to this page and download the library: Download fanqingxuan/gen-models 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/ */

    

fanqingxuan / gen-models example snippets


class Base {
    public function __construct() {
        
    }
    
    public function find() {
        
    }
    
    public function findAll() {
        
    }
    
    public function update() {
        
    }
    
    public function query() {
        
    }
    
    public function insert() {
        
    }
}

class User extends Base {
    
}

class Post extends Base {
    
}


class User {
    public $primaryKey = 'user_id';
    
    public static function tableName() {
        return "tbl_users";
    }
} 

composer 



/**
 * Generate by generate-model-tool
 * @name UsersModel
 * @desc UsersModel类, 主要用来访问数据库
 * @author Json
 * @see http://github.com/fanqingxuan/gen-models
 */
class UsersModel extends BaseModel {

   /**
    * table primary key
    */
   protected $primary_key = 'user_id';

   /**
    * @return string
    */
   public static function tableName()
   {
        return 'users';
   }

}

$ [email protected]:fanqingxuan/gen-models.git  //gen-models在这个仓库的根目录,可以拿下来直接用