Kaynağa Gözat

[HttpKernel] renamed default profiler table to sf_profiler_data

Fabien Potencier 14 yıl önce
ebeveyn
işleme
f48512cd54

+ 2 - 2
src/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php

@@ -23,7 +23,7 @@ class MysqlProfilerStorage extends PdoProfilerStorage
      */
     protected function initDb()
     {
-        if (is_null($this->db)) {
+        if (null === $this->db) {
             if ('mysql' !== substr($this->dsn, 0, 5)) {
                 throw new \RuntimeException('Please check your configuration. You are trying to use Mysql with a wrong dsn. "' . $this->dsn . '"');
             }
@@ -33,7 +33,7 @@ class MysqlProfilerStorage extends PdoProfilerStorage
             }
 
             $db = new \PDO($this->dsn, $this->username, $this->password);
-            $db->exec('CREATE TABLE IF NOT EXISTS data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, KEY (created_at), KEY (ip), KEY (url), KEY (parent))');
+            $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, KEY (created_at), KEY (ip), KEY (url), KEY (parent))');
 
             $this->db = $db;
         }

+ 6 - 6
src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php

@@ -53,7 +53,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
         $criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : '';
 
         $db = $this->initDb();
-        $tokens = $this->fetch($db, 'SELECT token, ip, url, time, parent FROM data '.$criteria.' ORDER BY time DESC LIMIT '.((integer) $limit), $args);
+        $tokens = $this->fetch($db, 'SELECT token, ip, url, time, parent FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((integer) $limit), $args);
         $this->close($db);
 
         return $tokens;
@@ -66,7 +66,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
      {
          $db = $this->initDb();
          $args = array(':token' => $token);
-         $tokens = $this->fetch($db, 'SELECT token FROM data WHERE parent = :token LIMIT 1', $args);
+         $tokens = $this->fetch($db, 'SELECT token FROM sf_profiler_data WHERE parent = :token LIMIT 1', $args);
          $this->close($db);
 
         return $tokens;
@@ -79,7 +79,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
     {
         $db = $this->initDb();
         $args = array(':token' => $token);
-        $data = $this->fetch($db, 'SELECT data, parent, ip, url, time FROM data WHERE token = :token LIMIT 1', $args);
+        $data = $this->fetch($db, 'SELECT data, parent, ip, url, time FROM sf_profiler_data WHERE token = :token LIMIT 1', $args);
         $this->close($db);
         if (isset($data[0]['data'])) {
             return array($data[0]['data'], $data[0]['parent'], $data[0]['ip'], $data[0]['url'], $data[0]['time']);
@@ -104,7 +104,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
             ':created_at'   => time(),
         );
         try {
-            $this->exec($db, 'INSERT INTO data (token, parent, data, ip, url, time, created_at) VALUES (:token, :parent, :data, :ip, :url, :time, :created_at)', $args);
+            $this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, url, time, created_at) VALUES (:token, :parent, :data, :ip, :url, :time, :created_at)', $args);
             $this->cleanup();
             $status = true;
         } catch (\Exception $e) {
@@ -121,7 +121,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
     public function purge()
     {
         $db = $this->initDb();
-        $this->exec($db, 'DELETE FROM data');
+        $this->exec($db, 'DELETE FROM sf_profiler_data');
         $this->close($db);
     }
 
@@ -146,7 +146,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
     protected function cleanup()
     {
         $db = $this->initDb();
-        $this->exec($db, 'DELETE FROM data WHERE created_at < :time', array(':time' => time() - $this->lifetime));
+        $this->exec($db, 'DELETE FROM sf_profiler_data WHERE created_at < :time', array(':time' => time() - $this->lifetime));
         $this->close($db);
     }
 

+ 7 - 7
src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php

@@ -25,7 +25,7 @@ class SqliteProfilerStorage extends PdoProfilerStorage
      */
     protected function initDb()
     {
-        if (is_null($this->db) || $this->db instanceof \SQLite3) {
+        if (null === $this->db || $this->db instanceof \SQLite3) {
             if ('sqlite' !== substr($this->dsn, 0, 6 )) {
                 throw new \RuntimeException('You are trying to use Sqlite with a wrong dsn. "'.$this->dsn.'"');
             }
@@ -37,12 +37,12 @@ class SqliteProfilerStorage extends PdoProfilerStorage
                 throw new \RuntimeException('You need to enable either the SQLite or PDO_SQLite extension for the profiler to run properly.');
             }
 
-            $db->exec('CREATE TABLE IF NOT EXISTS data (token STRING, data STRING, ip STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER)');
-            $db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON data (created_at)');
-            $db->exec('CREATE INDEX IF NOT EXISTS data_ip ON data (ip)');
-            $db->exec('CREATE INDEX IF NOT EXISTS data_url ON data (url)');
-            $db->exec('CREATE INDEX IF NOT EXISTS data_parent ON data (parent)');
-            $db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON data (token)');
+            $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token STRING, data STRING, ip STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER)');
+            $db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON sf_profiler_data (created_at)');
+            $db->exec('CREATE INDEX IF NOT EXISTS data_ip ON sf_profiler_data (ip)');
+            $db->exec('CREATE INDEX IF NOT EXISTS data_url ON sf_profiler_data (url)');
+            $db->exec('CREATE INDEX IF NOT EXISTS data_parent ON sf_profiler_data (parent)');
+            $db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON sf_profiler_data (token)');
 
             $this->db = $db;
         }