コード例 #1
0
 protected function tearDown()
 {
     try {
         $this->db->exec('DROP TABLE IF EXISTS test');
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
コード例 #2
0
 /**
  * Drop ThinkUp tables
  *
  * @TODO: Use PDO instead of deprecated Database class.
  * @param Database $db
  */
 public function drop($db)
 {
     global $TEST_DATABASE;
     //Delete test data by dropping all existing tables
     $q = "SHOW TABLES FROM " . $TEST_DATABASE;
     $result = $db->exec($q);
     while ($row = mysql_fetch_assoc($result)) {
         $q = "DROP TABLE " . $row['Tables_in_' . $TEST_DATABASE];
         $db->exec($q);
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: nicefirework/sharecloud
 public static function insertTables(Smarty $smarty)
 {
     if (ConfigurationChecks::getResult() != CheckResult::OK) {
         header('Location: index.php');
         exit;
     }
     $sql = file_get_contents(SYSTEM_ROOT . '/install/install.sql');
     try {
         $db = new Database('mysql:dbname=' . DATABASE_NAME . ';host=' . DATABASE_HOST, DATABASE_USER, DATABASE_PASS);
         $sql = $db->prepare('SHOW TABLES');
         $sql->execute();
         if ($sql->rowCount() == 0 || Utils::getGET('confirm', false) != false) {
             $insert = file_get_contents('./install.sql');
             $db->exec($insert);
             header('Location: index.php?action=user');
             exit;
         } else {
             $smarty->assign('heading', 'Database tables');
             $smarty->assign('curStep', 2);
             $smarty->display('confirm.tpl');
         }
     } catch (PDOException $e) {
         $smarty->assign('heading', 'Database tables');
         $smarty->assign('error', $e->getMessage());
         $smarty->assign('url', 'index.php?action=tables&confirm=yes');
         $smarty->assign('curStep', 2);
         $smarty->display('error.tpl');
     }
 }
コード例 #4
0
ファイル: Install.php プロジェクト: paragonie/airship
 /**
  * Set up the database tables, views, etc.
  *
  */
 protected function finalDatabaseSetup()
 {
     $this->db = $this->finalDatabasePrimary();
     // Let's iterate through the SQL files and run them all
     $driver = $this->db->getDriver();
     $files = \Airship\list_all_files(ROOT . '/Installer/sql/' . $driver, 'sql');
     \sort($files);
     foreach ($files as $file) {
         $query = \file_get_contents($file);
         try {
             $this->db->exec($query);
         } catch (\PDOException $e) {
             var_dump($e->getMessage());
             var_dump($query);
             exit(1);
         }
     }
     switch ($driver) {
         case 'pgsql':
             $this->databaseFinalPgsql();
             break;
         default:
             die('Unsupported primary database driver');
     }
 }
コード例 #5
0
 public function __construct(API $base, Database $database, $key_prefix)
 {
     parent::__construct($key_prefix, $base);
     $this->database = $database;
     if ($database instanceof MySQL) {
         $sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key VARCHAR(255) NOT NULL, item_expires INT(11) UNSIGNED NOT NULL, item_value LONGTEXT NOT NULL, UNIQUE KEY (item_key)) ENGINE = InnoDB DEFAULT CHARSET=UTF8';
         $database->exec($sql);
     }
     if ($database instanceof SQLite) {
         $sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key TEXT, item_expires INTEGER, item_value TEXT, UNIQUE (item_key))';
         $database->exec($sql);
     }
     if ($database instanceof PostgreSQL) {
         $sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key VARCHAR(255) NOT NULL, item_expires INTEGER NOT NULL, item_value TEXT NOT NULL, UNIQUE (item_key))';
         $database->exec($sql);
     }
 }
コード例 #6
0
 public function install()
 {
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `users`\n\t\t(\n\t\t\t`uni_id`\t\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\t`role`\t\t\t\t\tvarchar(12)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`flair`\t\t\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`clearance`\t\t\t\ttinyint(1)\t\t\t\t\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\t`handle`\t\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`display_name`\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`timezone`\t\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`date_joined`\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t`date_lastLogin`\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\t`auth_token`\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\tUNIQUE (`uni_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY KEY(uni_id) PARTITIONS 7;\n\t\t");
     // Vertical partitioning of the user's table. This creates duplicate content, but will greatly speed up
     // lookup times for handles. There is overhead for two tables, but its a negligible impact compared to the
     // horizontal partitioning we gain on the user's table.
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `users_handles`\n\t\t(\n\t\t\t`handle`\t\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`uni_id`\t\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\tUNIQUE (`handle`, `uni_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8\n\t\t\n\t\tPARTITION BY RANGE COLUMNS(handle) (\n\t\t\tPARTITION p0 VALUES LESS THAN ('a'),\n\t\t\tPARTITION p1 VALUES LESS THAN ('e'),\n\t\t\tPARTITION p2 VALUES LESS THAN ('i'),\n\t\t\tPARTITION p3 VALUES LESS THAN ('m'),\n\t\t\tPARTITION p4 VALUES LESS THAN ('q'),\n\t\t\tPARTITION p5 VALUES LESS THAN ('u'),\n\t\t\tPARTITION p6 VALUES LESS THAN MAXVALUE\n\t\t);\n\t\t");
     return $this->isInstalled();
 }
コード例 #7
0
ファイル: database_test.php プロジェクト: karbassi/twitalytic
 function testExecutingSQLWithUnSetTablePrefixShouldFail()
 {
     global $TWITALYTIC_CFG;
     $TWITALYTIC_CFG['table_prefix'] = 'tw_';
     $this->expectException();
     $db = new Database($TWITALYTIC_CFG);
     $conn = $db->getConnection();
     $sql_result = $db->exec("SELECT \n\t\t\t\tuser_id \n\t\t\tFROM \n\t\t\t\t%prefix%users \n\t\t\tWHERE \n\t\t\t\tuser_id = 930061");
     $db->closeConnection($conn);
 }
コード例 #8
0
ファイル: registration.php プロジェクト: Abhilaash/Planner
function uploadData($name, $username, $password, $email)
{
    $db = new Database();
    $db->exec("CREATE TABLE IF NOT EXISTS recipes (username TEXT PRIMARY KEY, password TEXT, email TEXT, name TEXT)");
    $stmt = $db->prepare("INSERT INTO recipes VALUES (:us, :ps, :em, :n)");
    $stmt->bindValue(':us', $username);
    $stmt->bindValue(':ps', $password);
    $stmt->bindValue(':em', $email);
    $stmt->bindValue(':n', $name);
    $stmt->execute();
}
コード例 #9
0
ファイル: todo_mapper.php プロジェクト: hoverlord/ff2do
 public function archiveTodo($item_id)
 {
     $db_link = new Database();
     $sql = 'SELECT todo_archived FROM todos WHERE todo_id = "' . (int) $item_id . '"';
     $toggle = 1;
     if ($db_link->query($sql)->fetch()->todo_archived == 1) {
         $toggle = 0;
     }
     $sql = 'UPDATE todos SET todo_archived = ' . $toggle . ' WHERE todo_id = "' . (int) $item_id . '"';
     $db_link->exec($sql);
 }
コード例 #10
0
ファイル: project_mapper.php プロジェクト: hoverlord/ff2do
 public function archiveProject($id)
 {
     $db_link = new Database();
     $sql = 'SELECT project_archived FROM projects WHERE project_id = "' . (int) $id . '"';
     $toggle = 1;
     if ($db_link->query($sql)->fetch()->project_archived == 1) {
         $toggle = 0;
     }
     $sql = 'UPDATE projects SET project_archived = ' . $toggle . ' WHERE project_id = "' . (int) $id . '"';
     $db_link->exec($sql);
 }
コード例 #11
0
 public function exec($sql, array $params = null)
 {
     try {
         return parent::exec($sql, $params);
     } catch (PDOException $e) {
         $info = $this->errorInfo();
         switch ($info[1]) {
             case 8:
                 throw new ReadOnlyDatabaseException();
             default:
                 throw $e;
         }
     }
 }
コード例 #12
0
ファイル: database_test.php プロジェクト: BenBtg/thinktank
 function testExecutingSQLWithUnSetTablePrefixShouldFail()
 {
     global $THINKTANK_CFG;
     $THINKTANK_TEST_CFG['table_prefix'] = 'tw_';
     $THINKTANK_TEST_CFG['db_password'] = $THINKTANK_CFG['db_password'];
     $THINKTANK_TEST_CFG['db_host'] = $THINKTANK_CFG['db_host'];
     $THINKTANK_TEST_CFG['db_name'] = $THINKTANK_CFG['db_name'];
     $THINKTANK_TEST_CFG['db_user'] = $THINKTANK_CFG['db_user'];
     $this->expectException();
     $db = new Database($THINKTANK_TEST_CFG);
     $conn = $db->getConnection();
     $sql_result = $db->exec("SELECT\n\t\t\t\tuser_id \n\t\t\tFROM \n\t\t\t\t%prefix%users \n\t\t\tWHERE \n\t\t\t\tuser_id = 930061");
     $db->closeConnection($conn);
 }
コード例 #13
0
 public static function copy($sourceTable, $destinationTable, $sqlWhere = "", $sqlArray = array(), $limit = 1000, $move = false)
 {
     // Protect Tables
     if (!IsSanitized::variable($destinationTable) or !IsSanitized::variable($sourceTable)) {
         return false;
     }
     // Make sure the backup table exists
     Database::exec("CREATE TABLE IF NOT EXISTS " . $destinationTable . " LIKE " . $sourceTable);
     // Begin the Database_Transfer
     Database::startTransaction();
     // Insert Rows into Database_Transfer Table
     Database::query("INSERT INTO " . $destinationTable . " SELECT * FROM " . $sourceTable . ($sqlWhere != "" ? " WHERE " . Sanitize::variable($sqlWhere, " ,`!=<>?()") : "") . ($limit ? ' LIMIT ' . (int) $limit : ''), $sqlArray);
     $newCount = Database::$rowsAffected;
     if ($move === true) {
         // Delete Rows from Original Table (if applicable)
         Database::query("DELETE FROM " . $sourceTable . ($sqlWhere != "" ? " WHERE " . Sanitize::variable($sqlWhere, " ,`!=<>?()") : ""), $sqlArray);
         // If the number of inserts matches the number of deletions, commit the transaction
         return Database::endTransaction($newCount == Database::$rowsAffected);
     }
     return Database::endTransaction();
 }
コード例 #14
0
 /**
  * atualiza os dados no BD
  *
  * @param Pessoa $pessoa
  * @return int pessoa id
  */
 public function atualizar(Pessoa $pessoa)
 {
     try {
         self::valida($pessoa, "atualizar");
         $this->values = $pessoa->getPessoaValores();
         $this->fields = array_keys($pessoa->getPessoaValores());
         $this->sql = "UPDATE pessoa SET\n\t\t\t\t\t  nome = ?\n\t\t\t\t\t, email=? \n\t\t\t\t\t, endereco=?\n\t\t\t\t\t, complemento=?\n\t\t\t\t\t, numero=?\n\t\t\t\t\t, cep=?\n\t\t\t\t\t, UF = ?\n\t\t\t\t\t, cidade = ?\n\t\t\t\t\t, bairro =?\n\t\t\t\t\t, idresiduo =?\n\t\t\t\t\t, limitecredito =?\n\t\t\t\t\t, inadimplente =?\n\t\t\t\t\t, idempresa =?\n                                        , idcontato = ?\n\t\t\t\t\tWHERE id=?";
         $this->values = array();
         $this->values = array($pessoa->nome, $pessoa->email, $pessoa->endereco, $pessoa->complemento, $pessoa->numero, $pessoa->cep, $pessoa->UF, $pessoa->cidade, $pessoa->bairro, $pessoa->idresiduo, $pessoa->limitecredito, $pessoa->inadimplente, $pessoa->idempresa, $pessoa->idcontato, $pessoa->id);
         parent::exec();
         $telefoneDAO = new TelefoneDAO();
         $telefoneDAO->atualizarTelefones($pessoa->id, $pessoa->telefones);
         $telefoneDAO->apagarTelefones($pessoa->id, explode(",", $_POST['removerTels']));
         $enderecoDAO = new EnderecoDAO();
         $enderecoDAO->atualizarEnderecos($pessoa->id, $pessoa->enderecos);
     } catch (Exception $e) {
         $erro = new FormException();
         $erro->addError($e->getMessage());
         throw $erro;
     }
     return $pessoa->id;
 }
コード例 #15
0
ファイル: DBTable.php プロジェクト: amineabri/Fiesta
 public function clear()
 {
     Database::exec('TRUNCATE TABLE ' . $this->name . ';');
 }
コード例 #16
0
 /**
  * Functional Test for Timeout.
  * @depends testPrepare
  */
 public function testTimeout()
 {
     // Setup our new Database class
     $db = new Database(PDO_DSN, PDO_USERNAME, PDO_PASSWORD, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
     // Make the timeout 1 second.
     $db->exec('SET GLOBAL connect_timeout=1');
     $db->exec('SET GLOBAL wait_timeout=1');
     // Wait two seconds.
     sleep(2);
     // Run a query to see if it reconnects.
     $statement = $db->prepare('SELECT * FROM editions');
     $result = $statement->execute();
     $this->assertEquals(true, $result, 'Database reconnects on timeout.');
 }
コード例 #17
0
 public function install()
 {
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `site_variables`\n\t\t(\n\t\t\t`key_group`\t\t\t\tvarchar(22)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`key_name`\t\t\t\tvarchar(32)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`value`\t\t\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\tUNIQUE (`key_group`, `key_name`)\n\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ;\n\t\t");
     return $this->isInstalled();
 }
コード例 #18
0
ファイル: Model.php プロジェクト: amineabri/Fiesta
 public function edit()
 {
     $sql = "update " . $this->DBtable . " set ";
     //
     $data = $this->getData();
     //
     $i = 0;
     foreach ($data as $key => $value) {
         if ($i == 0) {
             $sql .= "{$key}='{$value}'";
         } else {
             $sql .= ",{$key}='{$value}'";
         }
         $i++;
     }
     //
     $key = $this->getPKvalue();
     $sql .= " where " . $this->key . "='" . $key . "'";
     //
     return Database::exec($sql);
 }
コード例 #19
0
<?php

$basepath = SYSTEM_ROOT . '/upgrade/scripts/';
try {
    $sql = file_get_contents($basepath . 'upgrade-1.1.0-1.2.0-pre.sql');
    $db = new Database('mysql:dbname=' . DATABASE_NAME . ';host=' . DATABASE_HOST, DATABASE_USER, DATABASE_PASS);
    $db->exec($sql);
    $sql = $db->query('SELECT _id, password, salt, permission FROM file_permissions');
    while ($row = $sql->fetch()) {
        $query = $db->prepare('UPDATE files SET password = :password, salt = :salt, permission = :permission WHERE file_permissions_ID = :id');
        $query->execute(array(':id' => $row['_id'], ':password' => $row['password'], ':salt' => $row['salt'], ':permission' => $row['permission']));
    }
    $sql = file_get_contents($basepath . 'upgrade-1.1.0-1.2.0-post.sql');
    $db->exec($sql);
    header('Location: index.php?action=success');
    exit;
} catch (PDOException $e) {
    $smarty->assign('heading', 'Error during upgrade');
    $smarty->assign('error', $e->getMessage());
    $smarty->assign('url', 'index.php');
    $smarty->assign('curStep', 1);
    $smarty->display('error.tpl');
    exit;
}
コード例 #20
0
ファイル: User.php プロジェクト: NideXTC/CoursYNov
 public function create()
 {
     $sql = "INSERT INTO users\n                SET name = :name,\n                first_name = :first_name,\n                password = :password,\n                email = :email";
     Database::exec($sql, [':name' => $this->_name, ':first_name' => $this->_first_name, ':password' => $this->_password, ':email' => $this->_email]);
 }
コード例 #21
0
<?php

require 'database.php';
$id = $_GET["id"];
$db = new Database();
$db->exec("DELETE FROM todos WHERE idno = " . $id . ";");
header("Location: index.php");
//print_r($row);
コード例 #22
0
ファイル: Model.php プロジェクト: amineabri/ARFiesta
 public function delete($where = null)
 {
     //print_r(self::$keys);
     $vars = $this->rows();
     if (empty($where)) {
         $sql = "delete from " . $this->table . " where ";
         //
         $i = 0;
         //
         foreach ($this->keys as $key => $value) {
             if ($i == 0) {
                 $sql .= "{$value}='" . $vars[$value] . "'";
             } else {
                 $sql .= " && {$value}='" . $vars[$value] . "'";
             }
             $i++;
         }
     } else {
         $sql = "delete from " . $this->table . " where ";
         $sql .= $where;
         //
     }
     //echo $sql;
     return Database::exec($sql);
 }
コード例 #23
0
 public static function changeCollation($table, $type = "utf8")
 {
     return Database::exec("ALTER TABLE " . Sanitize::variable($table) . " CONVERT TO CHARACTER SET " . Sanitize::variable($type, "-") . ";");
 }
コード例 #24
0
 public function install()
 {
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `log_threat_tracker` (\n\t\t\t\n\t\t\t`severity`\t\t\t\ttinyint(1)\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t`date_logged`\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\t`threat_type`\t\t\tvarchar(12)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`threat_text`\t\t\tvarchar(250)\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`uni_id`\t\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t`ip`\t\t\t\t\tvarchar(45)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`function_call`\t\t\tvarchar(100)\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`file_path`\t\t\t\tvarchar(32)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`file_line`\t\t\t\tsmallint(5)\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\t`url_path`\t\t\t\tvarchar(64)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`data_captured`\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\tINDEX (`severity`, `date_logged`),\n\t\t\tINDEX (`uni_id`, `ip`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n\t\t");
     return $this->isInstalled();
 }
コード例 #25
0
ファイル: index.php プロジェクト: davemcphee/AustinDecoded
         * A specific error page has been created for database connection failures, display that.
         */
        if (defined('ERROR_PAGE_DB')) {
            require $_SERVER['DOCUMENT_ROOT'] . '/' . ERROR_PAGE_DB;
            exit;
        } else {
            die(SITE_TITLE . ' is having some database trouble right now. Please check back in a few minutes.');
        }
    }
}
/*
 * Prior to PHP v5.3.6, the PDO does not pass along to MySQL the DSN charset configuration option,
 * and it must be done manually.
 */
if (version_compare(PHP_VERSION, '5.3.6', '<')) {
    $db->exec("SET NAMES utf8");
}
/*
 * We're going to need access to the database connection throughout the site.
 */
global $db;
/*
 * Include Solarium's autoloader, for queries to Solr.
 */
require 'Solarium/Autoloader.php';
Solarium_Autoloader::register();
/*
 * Include the custom functions file.
 */
require CUSTOM_FUNCTIONS;
/*
コード例 #26
0
ファイル: functions.php プロジェクト: Kheros/Plexis
function get_database_connections($show)
{
    // Check if provided info is correct
    $Realm = new Database();
    $r_info = array('driver' => 'mysql', 'host' => $_POST['rdb_host'], 'port' => $_POST['rdb_port'], 'username' => $_POST['rdb_username'], 'password' => $_POST['rdb_password'], 'database' => $_POST['rdb_name']);
    // Attempt to connect
    $connect = $Realm->connect($r_info);
    if ($connect !== true) {
        show_error('Counld Not connect to the Realm database!<br /><br />Error: ' . $connect);
        die;
    } else {
        if ($show) {
            output_message('success', 'Successfully Connected to Realm DB.');
        }
    }
    // Plexis DB
    $DB = new Database();
    $info = array('driver' => 'mysql', 'host' => $_POST['db_host'], 'port' => $_POST['db_port'], 'username' => $_POST['db_username'], 'password' => $_POST['db_password'], 'database' => $_POST['db_name']);
    // Attempt to connect
    $connect = $DB->connect($info);
    if ($connect !== true) {
        // Something went wrong, try opening information_schema instead.
        $DB = new Database();
        $info["database"] = "information_schema";
        // If we can connect to the information schema, then the database doesnt exist, so we create it
        $connect = $DB->connect($info);
        if ($connect === true) {
            //Create our database if it doesn't exist.
            $query = "CREATE DATABASE `" . $_POST["db_name"] . "`;";
            if ($DB->exec($query)) {
                // Select the newly created database
                $DB->exec("use " . $_POST['db_name'] . ";");
                goto Success;
                //Skip the error message below.
            }
        }
        show_error('Counld Not select Plexis database!<br /><br />Error: ' . $connect);
        die;
    } else {
        Success:
        if ($show) {
            output_message('success', 'Successfully Connected to Plexis DB.');
        }
    }
    return array('plexis' => $DB, 'realm' => $Realm);
}
コード例 #27
0
 public function install()
 {
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `log_email`\n\t\t(\n\t\t\t`id`\t\t\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tAUTO_INCREMENT,\n\t\t\t\n\t\t\t`recipient`\t\t\t\tvarchar(72)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`subject`\t\t\t\tvarchar(42)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`message`\t\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`details`\t\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\n\t\t\t`date_sent`\t\t\t\tint(10)\t\t\tunsigned\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\tPRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY KEY (`id`) PARTITIONS 5;\n\t\t");
     return $this->isInstalled();
 }
コード例 #28
0
ファイル: exec_migration.php プロジェクト: amineabri/Fiesta
    $pieces2[] = $pieces[1];
    //
}
//echo "\n";
$mx = max($f);
//
$ind = 0;
$i = 0;
//
foreach ($pieces2 as $value) {
    //echo $value."\n";
    if (strpos($value, $mx) !== false) {
        $ind = $i;
    }
    $i++;
}
$link = $r[$ind];
//
try {
    include_once $link;
    if (up()) {
        if (Schema::existe(Config::get('database.migration'))) {
            Database::exec("update " . Config::get('database.migration') . " set status_schema='executed' where name_schema='" . $name . "' and date_schema='" . $time . "'");
        }
        echo "Schéma executé";
    } else {
        echo "Schema n'est pas executé" . Database::execErr();
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
コード例 #29
0
ファイル: Entity.php プロジェクト: SkysteedDevelopment/Deity
 public function __construct($entityID = "", $full = false)
 {
     // Prepare Variables
     $this->class = get_called_class();
     $this->id = $entityID ? Sanitize::text($entityID) : "_" . Security_Hash::value(microtime(), 12);
     // Attempt to retrieve this object
     if (!($data = Database::selectValue("SELECT `data` FROM `entity_" . $this->class . "` WHERE `id`=? LIMIT 1", [$this->id]))) {
         $data = '[]';
         if (!Database::query("INSERT INTO `entity_" . $this->class . "` (id, data) VALUES (?, ?)", [$this->id, json_encode([])])) {
             // Create the table if it doesn't exist
             Database::exec("\n\t\t\t\tCREATE TABLE IF NOT EXISTS `entity_" . $this->class . "`\n\t\t\t\t(\n\t\t\t\t\t`id`\t\t\t\tvarchar(32)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\t\t`data`\t\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t\t\t\n\t\t\t\t\tUNIQUE (`id`)\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY KEY (`id`) PARTITIONS 7;");
             Database::query("INSERT INTO `entity_" . $entityClass . "` (id, data) VALUES (?, ?)", [$this->id, $data]);
         }
     }
     $this->data = json_decode($data, true);
     $this->data['id'] = $this->id;
     // If the object is supposed to retrieve all objects
     if ($full) {
         // Get all of the entity's relationships
         $results = Database::selectMultiple("SELECT attribute, related_id FROM `entity_relationships` WHERE entity_class=? AND entity_id=?", [$class, $entityID]);
         foreach ($results as $result) {
             $this->data[$result['attribute']][] = $result['related_id'];
         }
     }
 }
コード例 #30
0
 public static function sql()
 {
     Database::exec("\n\t\tCREATE TABLE IF NOT EXISTS `cache`\n\t\t(\n\t\t\t`key`\t\t\tvarchar(28)\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`value`\t\t\ttext\t\t\t\t\t\tNOT NULL\tDEFAULT '',\n\t\t\t`expire`\t\tint(10)\t\t\t\t\t\tNOT NULL\tDEFAULT '0',\n\t\t\t\n\t\t\tUNIQUE (`key`),\n\t\t\tINDEX (`expire`)\n\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ;\n\t\t");
     return Database_Meta::columnsExist("cache", array("key", "value", "expire"));
 }