Exemplo n.º 1
0
 /**
  * @param string $query
  */
 public final function __construct($sql, $connectionName = 'main')
 {
     if (preg_match(static::$queryTypeRegexp, $sql) != 1) {
         throw new WrongQueryTypeException("The query type '" . get_class($this) . "' is not intended for that query.");
     }
     $this->sql = $sql;
     $this->mysqli = Connection::getInstance($connectionName)->mysqli;
 }
Exemplo n.º 2
0
 /**
  *
  * Constructor for all inheriting statements. This behaviour should be the
  * same for every inheriting class, which is why it is final.
  * @param string $query
  * @param string $types
  * @throws MySQLi_Classes\Exceptions\ParameterCountMismatchException
  * @throws MySQLi_Classes\Exceptions\ErrorException
  */
 public final function __construct($sql, $paramTypes = null, $connectionName = 'main')
 {
     if (preg_match(static::$queryTypeRegexp, $sql) != 1) {
         throw new WrongQueryTypeException("The query type '" . get_class($this) . "' is not intended for that query.");
     }
     $this->sql = $sql;
     $this->mysqli = Connection::getInstance($connectionName)->mysqli;
     $this->statement = $this->mysqli->prepare($this->sql);
     if ($this->mysqli->errno > 0) {
         throw ErrorException::findClass($this->mysqli, __LINE__);
     }
     if ($paramTypes == null) {
         $paramTypes = '';
     }
     if ($this->statement->param_count != strlen($this->paramTypes = $paramTypes)) {
         throw new ParameterCountMismatchException('There is a mismatch between the number of statement variable types and parameters.');
     }
 }
Exemplo n.º 3
0
<?php

use MySQLi_Classes\Connection;
require_once 'MySQLi_Classes/autoloader.inc.php';
$properties = parse_ini_file('build.properties');
$GLOBALS['mysqli'] = new MySQLi($properties['mysql.hostname'], $properties['mysql.username'], $properties['mysql.password'], $properties['test.schema'], $properties['mysql.port']);
$GLOBALS['mysqli']->set_charset("utf8");
$GLOBALS['schema'] = $properties['test.schema'];
$GLOBALS['comparisonSchema'] = $properties['test.schema.comparison'];
Connection::connect($GLOBALS['mysqli']);
require_once __DIR__ . '/TableComparisonTestCase.class.php';