rabin 1 vuosi sitten
vanhempi
commit
a788f8743e
5 muutettua tiedostoa jossa 20 lisäystä ja 9 poistoa
  1. 5 0
      boot.php
  2. 1 5
      src/Dever/Config.php
  3. 7 1
      src/Dever/Sql.php
  4. 3 3
      src/Dever/Store/Pdo.php
  5. 4 0
      src/Dever/View.php

+ 5 - 0
boot.php

@@ -46,6 +46,11 @@ class Dever
     }
     public static function call($class, $param = array(), $path = '')
     {
+        if (strpos($class, '?')) {
+            list($class, $temp) = explode('?', $class);
+            parse_str($temp, $temp);
+            $param[0] = array_merge($param[0], $temp);
+        } 
         if (strpos($class, '.')) {
             list($class, $method) = explode('.', $class);
             $call = 'load';

+ 1 - 5
src/Dever/Config.php

@@ -21,11 +21,7 @@ class Config
     protected static function env($path)
     {
         if (empty($_SERVER['DEVER_ENV_NAME'])) {
-            if (isset($_SERVER['SERVER_NAME'])) {
-                $_SERVER['DEVER_ENV_NAME'] = $_SERVER['SERVER_NAME'];
-            } else {
-                $_SERVER['DEVER_ENV_NAME'] = 'localhost';
-            }
+            $_SERVER['DEVER_ENV_NAME'] = 'localhost';
         }
         if (empty($_SERVER['DEVER_ENV_PATH'])) {
             $_SERVER['DEVER_ENV_PATH'] = $path . 'env' . DIRECTORY_SEPARATOR;

+ 7 - 1
src/Dever/Sql.php

@@ -23,7 +23,10 @@ class Sql
     }
     public static function create($config)
     {
-        $sql = 'CREATE TABLE `' . $config['table'] . '`(';
+        if (isset(Config::get('setting')['database']['create']) && !Config::get('setting')['database']['create']) {
+            return;
+        }
+        $sql = 'DROP TABLE IF EXISTS `' . $config['table'] . '`;CREATE TABLE IF NOT EXISTS `' . $config['table'] . '`(';
         $struct = array('id' => array('name' => 'ID', 'type' => 'int(11)'),'cdate' => array('name' => 'cdate', 'type' => 'int(11)'));
         $struct = array_merge($struct, $config['struct']);
         foreach ($struct as $k => $v) {
@@ -288,6 +291,9 @@ class Sql
     {
         $sql = 'INSERT INTO `' . $table . '` SET ';#IGNORE
         foreach ($data as $k => $v) {
+            if (!$v && $v !== 0) {
+                continue;
+            }
             if ($field && empty($field[$k]) && strpos('id,cdate', $k) === false) {
                 continue;
             }

+ 3 - 3
src/Dever/Store/Pdo.php

@@ -38,7 +38,7 @@ class Pdo extends Base
         } catch (\PDOException $e) {
             if (strstr($e->getMessage(), 'Unknown database')) {
                 $this->create($setting);
-                $this->connect($setting);
+                return $this->connect($setting);
             } else {
                 Output::error($e->getMessage());
             }
@@ -97,8 +97,8 @@ class Pdo extends Base
                 $handle->execute($bind);
             } else {
                 if (strpos($sql, ';')) {
-                    $this->read->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, true);
-                    $this->read->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
+                    $this->$method->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, true);
+                    $this->$method->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
                 }
                 $handle = $this->$method->query($sql);
             }

+ 4 - 0
src/Dever/View.php

@@ -9,6 +9,10 @@ class View
         $project = Project::load($app);
         $template = self::template();
         $path = $path . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR;
+        if (strstr($project['path'], 'package')) {
+            $package_path = str_replace(DEVER_PATH, '', $project['path']);
+            $package_host = DEVER_PROTO . '://' . $_SERVER['HTTP_HOST'] . '/dever2/' . $package_path . $path;
+        }
         $host = $project['url'] . $path;
         $compile = File::get('compile' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . $file . '.php');
         Debug::add($compile, 'template');