예제 #1
0
 public function getDesiredSize()
 {
     $meta = $this->meta;
     $dbr = DBPool::get($meta['cluster'], $meta['dbname']);
     try {
         $res = $dbr->select('image', 'sum(img_size) as total');
     } catch (DBQueryError $e) {
         return false;
     }
     foreach ($res as $row) {
         $total = $row->total;
         if ($total === null) {
             $total = false;
         } else {
             $total = intval($total);
         }
         return $total;
     }
     return false;
 }
예제 #2
0
 function getDao()
 {
     Assert::isTrue($this->hasDao, '%s is dao-less entity', $this->name);
     if (!$this->dao) {
         $this->dao = new RdbmsDao($this->dbSchema ? DBPool::get($this->dbSchema) : DBPool::getDefault(), $this);
     }
     return $this->dao;
 }
예제 #3
0
try {
    $ormDomain = $domainBuilder->build();
    if ($code) {
        $generator = new OrmGenerator($autoDir, $publicDir);
        if ($regeneratePublic) {
            $generator->regeneratePublic();
        }
        $generator->generate($ormDomain);
    }
    if ($schema) {
        if (!$db && $ormDomain->getDbSchema()) {
            $db = $ormDomain->getDbSchema();
        }
        if ($db) {
            try {
                $dbObject = DBPool::get($db);
            } catch (ArgumentException $e) {
                stop("Unknown database reference: {$db}");
            }
        }
        if ($schemaFile) {
            $schemaFile = $appDir . DIRECTORY_SEPARATOR . $schemaFile;
        } else {
            $schemaFile = $appDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . strtolower($dbObject->getDialect()->getDBDriver()->getValue()) . '-' . pathinfo($xmlSchema, PATHINFO_FILENAME) . '.sql';
            $dir = dirname($schemaFile);
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
        }
        $schemaBuilder = new DBSchemaBuilder($ormDomain);
        $schemaConstructor = new SqlSchemaConstructor($schemaBuilder->build());