示例#1
0
    public function createLogic()
    {
        $src = __DIR__ . '/TplLogic.class.php';
        $dest = __DIR__ . '/' . $this->interface . 'Logic.class.php';
        $str = file_get_contents($src);
        $str = str_replace('TplModel', $this->modelName, $str);
        $str = str_replace('TplLogic', $this->interface . 'Logic', $str);
        file_put_contents($dest, $str);
    }
    public function createInterface()
    {
        $src = __DIR__ . '/TplInterface.class.php';
        $dest = __DIR__ . '/' . $this->interface . 'Interface.class.php';
        $typeStr = $this->getInterfaceFieldTypes();
        $str = file_get_contents($src);
        $str = str_replace('TplLogic', $this->interface . 'Logic', $str);
        $str = str_replace('TplInterface', $this->interface . 'Interface', $str);
        $str = str_replace('\'{$fieldTypes}\'', $typeStr, $str);
        file_put_contents($dest, $str);
    }
}
$dbName = 'hqoj';
$tableName = 'oj_solution';
$interface = 'OjSolution';
$obj = new ModelBuilder($dbName, $tableName, $interface);
$obj->createModel();
if (!empty($interface)) {
    $obj->createLogic();
    $obj->createInterface();
}
echo "done\n";
 /**
  * {@inheritDoc}
  */
 public function jsonSerialize()
 {
     return array_merge(parent::jsonSerialize(), ['exclusive' => $this->exclusive, 'arguments' => $this->arguments]);
 }
 public function getAccessToken($grantType, $clientId, $clientSecret, $scope)
 {
     $queryParams = [];
     $headers = ['Content-Type', 'application/x-www-form-urlencoded'];
     return ModelBuilder::create('General\\OAuthAccessToken', $this->send(Constants::MEDIA_SERVICES_OAUTH_URL, 'post', $queryParams, [Constants::OAUTH_GRANT_TYPE => $grantType, Constants::OAUTH_CLIENT_ID => $clientId, Constants::OAUTH_CLIENT_SECRET => $clientSecret, Constants::OAUTH_SCOPE => $scope], $headers));
 }
示例#4
0
            return self::\$_instance;
        }
        
        self::\$_instance = new self();
        return self::\$_instance;
    }
}
modelCode;
            $filePath = self::_getFilePath($fileDir, $className);
            file_put_contents($filePath, $code);
            echo "{$filePath} 生成成功!\n";
        }
        return true;
    }
    /**
     * 根据目录和类名创建文件路径
     * @param type $fileDir 目录位置
     * @param type $className 类名
     * @return type
     */
    private static function _getFilePath($fileDir, $className)
    {
        if (empty($fileDir)) {
            $fileDir = dirname(__FILE__);
        }
        return $fileDir . "/{$className}.class.php";
    }
}
$ret = ModelBuilder::createModels(DBConfig::$SERVER_SECONDMARKET_SLAVE, 'ganji_secondmarket', 'recycle_order');
echo $ret ? '创建成功' : '创建失败';
exit;
 /**
  * {@inheritDoc}
  */
 public function jsonSerialize()
 {
     return array_merge(parent::jsonSerialize(), ['type' => $this->type, 'internal' => $this->internal]);
 }
示例#6
0
<?php

require_once __DIR__ . '/../common.php';
define('BASE_MODEL_PATH', BUILDER_MODEL_PATH . '/base/');
define('MY_MODEL_PATH', BUILDER_MODEL_PATH . '/');
$db_master = pdo_factory($db->slave, null);
$eb = new ModelBuilder($db_master, $db->slave);
$eb->create();
class ModelBuilder
{
    private $pdo;
    private $db_info;
    function __construct($pdo = null, $db_info = null)
    {
        $this->pdo = $pdo;
        $this->db_info = $db_info;
    }
    function __destruct()
    {
        $this->pdo = null;
    }
    public function create()
    {
        $tableNameArray = $this->_getTables();
        if (!empty($tableNameArray)) {
            $cols = $this->_getColumnStructure($tableNameArray);
            if (file_exists(BASE_MODEL_PATH)) {
                $this->clearDirectory(BASE_MODEL_PATH);
            } else {
                if (!mkdir(BASE_MODEL_PATH, 0764, true)) {
                    die('Failed to create dir');