예제 #1
0
파일: Pdo.php 프로젝트: so222es/gesall
 /**
  * @override
  */
 public function exec($statement)
 {
     $start = microtime(true);
     $result = parent::exec($statement);
     $this->addLog(array('query' => $statement, 'time' => microtime(true) - $start, 'values' => array()));
     return $result;
 }
예제 #2
0
 /**
  * Destroys the database and user for the current application.
  * @return void
  */
 private function destroyMySQL()
 {
     $this->appNameRequired();
     if ($this->mysql->query('SHOW DATABASES LIKE \'db_' . $this->appname . '\';')->fetchObject()) {
         $this->writeln('Detected a Application MySQL user and database...');
         $this->mysql->exec('DROP DATABASE IF EXISTS `db_' . $this->appname . '`;');
         $this->mysql->exec('DROP USER \'' . $this->appname . '\'@\'' . $this->conf->mysql->confrom . '\';');
         $this->mysql->exec('FLUSH PRIVILEGES;');
     }
 }
예제 #3
0
 $dsn = "mysql:host={$_SESSION['config']['host']};dbname={$_SESSION['config']['database']}";
 $username = $_SESSION['config']['user'];
 $password = $_SESSION['config']['password'];
 $pdo = new Pdo($dsn, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"]);
 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 //执行建表语句
 if (is_file('data/install.sql')) {
     $sql = file_get_contents('data/install.sql');
     $sql = preg_replace('/^(\\/\\*|#.*).*/m', '', $sql);
     //替换表前缀
     $sql = str_replace('`hd_', '`' . $_SESSION['config']['prefix'], $sql);
     $result = preg_split('/;(\\r|\\n)/is', $sql);
     foreach ((array) $result as $r) {
         if (preg_match('/^\\s*[a-z]/i', $r)) {
             try {
                 $pdo->exec($r);
             } catch (PDOException $e) {
                 die('SQL执于失败:' . $r . '. ' . $e->getMessage());
             }
         }
     }
 }
 //更新系统版本号
 $version = (include 'data/upgrade.php');
 $sql = "INSERT INTO {$_SESSION['config']['prefix']}cloud (uid,username,webname,AppSecret,versionCode,releaseCode,createtime)\n\t\tVALUES(0,'','','','{$version['versionCode']}','{$version['releaseCode']}',0)";
 try {
     $pdo->exec($sql);
 } catch (PDOException $e) {
     die('SQL执于失败:' . $sql . '. ' . $e->getMessage());
 }
 //设置管理员帐号
예제 #4
0
파일: catalog.php 프로젝트: popov100/zip
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$src = new \Pdo('mysql:host=zip-tool.ru;port=3306;dbname=newstanki_ztool;charset=UTF8', 'newstanki_ztool', 'remotez');
$dst = new \Pdo('mysql:localhost;port=3306;dbname=zip_dev;charset=UTF8', 'zip_dev', 'zip_dev');
$src->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dst->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dst->exec('TRUNCATE TABLE category');
$dst->exec('TRUNCATE TABLE category_description');
$dst->exec('TRUNCATE TABLE category_path');
$dst->exec('TRUNCATE TABLE category_to_store');
$dst->exec('TRUNCATE TABLE manufacturer');
$dst->exec('TRUNCATE TABLE manufacturer_to_store');
$dst->exec('TRUNCATE TABLE folder');
$dst->exec('TRUNCATE TABLE folder_description');
$dst->exec('TRUNCATE TABLE stock_status');
$dst->exec('TRUNCATE TABLE `option`');
$dst->exec('TRUNCATE TABLE option_description');
$dst->exec('TRUNCATE TABLE option_value');
$dst->exec('TRUNCATE TABLE option_value_description');
$dst->exec('TRUNCATE TABLE attribute');
$dst->exec('TRUNCATE TABLE attribute_description');
$dst->exec('TRUNCATE TABLE attribute_group');
$dst->exec('TRUNCATE TABLE attribute_group_description');
$dst->exec('TRUNCATE TABLE product');
$dst->exec('TRUNCATE TABLE product_description');
$dst->exec('TRUNCATE TABLE product_to_store');
$dst->exec('TRUNCATE TABLE product_to_category');
$dst->exec('TRUNCATE TABLE product_option');