Exemplo n.º 1
0
    public function run()
    {
        $this->prepareTables();
        $repeats = $this->getRepeats();
        $value1 = 'string one';
        $value2 = 'string two';
        $value3 = 'string three';
        $bar = new CliProgressBar($repeats);
        for ($i = 1; $i <= $repeats; ++$i) {
            Timer::start();
            $sql = '
				INSERT INTO test (txt) VALUES
					(?),
					(?),
					(?)
			';
            Db::query($sql, [$value1, $value2, $value3]);
            Timer::stop();
            $bar->update($i);
        }
        $this->addResult('Real', Timer::get());
        PdoAdapter::instance()->getConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        Timer::reset();
        $bar = new CliProgressBar($repeats);
        for ($i = 1; $i <= $repeats; ++$i) {
            Timer::start();
            $sql = '
				INSERT INTO test (txt) VALUES
					(?),
					(?),
					(?)
			';
            Db::query($sql, [$value1, $value2, $value3]);
            Timer::stop();
            $bar->update($i);
        }
        $this->addResult('Emulated', Timer::get());
        $this->cleanup();
    }
Exemplo n.º 2
0
 /**
  * Delete data
  *
  * @param array|bool $ids Array of ID for delete
  *
  * @return bool
  */
 public function delete($ids = false)
 {
     $sql = $this->builder->delete($this, $ids);
     return Db::query($sql);
 }
Exemplo n.º 3
0
 public static final function cleanup()
 {
     $sql = 'DROP TABLE test';
     Db::query($sql);
 }
Exemplo n.º 4
0
 /**
  * @covers       Veles\DataBase\Db::query
  *
  * @dataProvider queryProvider
  *
  * @param $adapter
  * @param $sql
  * @param $params
  * @param $types
  */
 public function testQuery($adapter, $sql, $params, $types)
 {
     Db::setAdapter($adapter);
     if ($types) {
         Db::query($sql, $params, $types);
     } elseif ($params) {
         Db::query($sql, $params);
     } else {
         Db::query($sql);
     }
 }