/** * @return int */ public function getTotalCount() { $statement = $this->adapter->createStatement('SELECT COUNT(id) as cnt FROM ' . $this->table); $results = $statement->execute(); $row = $results->current(); return is_array($row) && isset($row['cnt']) ? (int) $row['cnt'] : 0; }
public function find($params) { $sql = new Sql($this->getAdapter()); $select = new Select(); $select->from($params['from']); if (!empty($params['columns'])) { $select->columns($params['columns']); } foreach ($params['where'] as $where) { $select->where($where); } foreach ($params['joins'] as $join) { if (empty($join['columns'])) { $join['columns'] = Select::SQL_STAR; } if (empty($join['type'])) { $join['type'] = Select::JOIN_INNER; } $select->join($join['name'], $join['on'], $join['columns'], $join['type']); } $query = $sql->getSqlStringForSqlObject($select); $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE); $data = $results->toArray(); if (empty($data)) { return false; } else { if (count($data) == 1) { return $data[0]; } else { return $data; } } }
public function onDispatch(MvcEvent $e) { if (!$e->getRequest() instanceof ConsoleRequest) { throw new RuntimeException('You can only use this action from a console!'); } $table = new Ddl\CreateTable('queue_messages'); $table->addColumn(new Ddl\Column\Integer('id', false, null, ['autoincrement' => true])); $table->addColumn(new Ddl\Column\Varchar('queue_name', 100)); $table->addColumn(new Ddl\Column\Integer('status', false)); $table->addColumn(new Ddl\Column\Varchar('options', 250)); $table->addColumn(new Ddl\Column\Text('message', null, true)); $table->addColumn(new Ddl\Column\Text('output', null, true)); $table->addColumn(new Ddl\Column\Datetime('started_dt', true)); $table->addColumn(new Ddl\Column\Datetime('finished_dt', true)); $table->addColumn(new Ddl\Column\Datetime('created_dt', false)); $table->addColumn(new Ddl\Column\Datetime('updated_dt', true)); $table->addConstraint(new Ddl\Constraint\PrimaryKey('id')); $sql = new Sql($this->dbAdapter); try { $this->dbAdapter->query($sql->buildSqlString($table), DbAdapter::QUERY_MODE_EXECUTE); } catch (\Exception $e) { // currently there are no db-independent way to check if table exists // so we assume that table exists when we catch exception } }
/** * Process the command * * @return integer */ public function processCommandTask() { // load autoload configuration from project $config = ConfigFactory::fromFiles(glob($this->params->projectConfigDir . '/autoload/{,*.}{global,development,local}.php', GLOB_BRACE)); // check for db config if (empty($config) || !isset($config['db'])) { $this->console->writeFailLine('task_crud_check_db_connection_no_config'); return 1; } // create db adapter instance try { $dbAdapter = new Adapter($config['db']); } catch (InvalidArgumentException $e) { $this->console->writeFailLine('task_crud_check_db_connection_config_inconsistent'); return 1; } // connect to database try { $connection = $dbAdapter->getDriver()->getConnection()->connect(); } catch (RuntimeException $e) { $this->console->writeFailLine('task_crud_check_db_connection_failed'); return 1; } $this->params->dbAdapter = $dbAdapter; return 0; }
private function create(SqlInterface $table) { try { $sql = new Sql($this->dbAdapter); $this->dbAdapter->query($sql->buildSqlString($table), Adapter::QUERY_MODE_EXECUTE); } catch (PDOException $e) { $message = $e->getMessage() . PHP_EOL; } }
/** * * @param string $tableName * @param array $data * @return bool */ public function insert($tableName, array $data) { $sql = new Sql($this->adapter); $insert = $sql->insert($tableName); $insert->values($data); $sqlString = $sql->getSqlStringForSqlObject($insert); $results = $this->adapter->query($sqlString, Adapter::QUERY_MODE_EXECUTE); return $results; }
/** * Get Database Connection * * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection */ public function getConnection() { if (!$this->connection) { $dbConfig = array('driver' => 'pdo', 'dsn' => 'mysql:dbname=ipc2013.testing.test;host=localhost;charset=utf8', 'user' => 'ipc2013', 'pass' => 'ipc2013'); $this->adapter = new Adapter($dbConfig); $this->connection = $this->createDefaultDBConnection($this->adapter->getDriver()->getConnection()->getResource(), 'ipc2013.testing.test'); } return $this->connection; }
public function executeQuery($sql) { if (!$this->dbAdapter) { /** @var Adapter dbAdapter */ $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'); } /** @var ResultSet $photos */ return $this->dbAdapter->query($sql, Adapter::QUERY_MODE_EXECUTE); }
protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, Adapter $adapter = null, $namedParameterPrefix = null) { // static counter for the number of times this method was invoked across the PHP runtime static $runtimeExpressionPrefix = 0; if ($adapter && (!is_string($namedParameterPrefix) || $namedParameterPrefix == '')) { $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix); } $sql = ''; $statementContainer = new StatementContainer(); $parameterContainer = $statementContainer->getParameterContainer(); // initialize variables $parts = $expression->getExpressionData(); $expressionParamIndex = 1; foreach ($parts as $part) { // if it is a string, simply tack it onto the return sql "specification" string if (is_string($part)) { $sql .= $part; continue; } if (!is_array($part)) { throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.'); } // process values and types (the middle and last position of the expression data) $values = $part[1]; $types = isset($part[2]) ? $part[2] : array(); foreach ($values as $vIndex => $value) { if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) { $values[$vIndex] = $platform->quoteIdentifierInFragment($value); } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) { // if prepareType is set, it means that this particular value must be // passed back to the statement in a way it can be used as a placeholder value if ($adapter) { $name = $namedParameterPrefix . $expressionParamIndex++; $parameterContainer->offsetSet($name, $value); $values[$vIndex] = $adapter->getDriver()->formatParameterName($name); continue; } // if not a preparable statement, simply quote the value and move on $values[$vIndex] = $platform->quoteValue($value); } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) { $values[$vIndex] = $value; } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_SELECT) { // process sub-select if ($adapter) { $values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $adapter, $statementContainer->getParameterContainer()) . ')'; } else { $values[$vIndex] = '(' . $this->processSubSelect($value, $platform) . ')'; } } } // after looping the values, interpolate them into the sql string (they might be placeholder names, or values) $sql .= vsprintf($part[0], $values); } $statementContainer->setSql($sql); return $statementContainer; }
/** * Load config from db-adapter * * @param \Zend\Db\Adapter\Adapter $db * @return array */ protected function loadConfig() { if (empty($this->dbAdapter)) { return $this->config; } $platform = $this->dbAdapter->getPlatform(); $driver = $this->dbAdapter->getDriver(); $query = $this->dbAdapter->query(' SELECT ' . $platform->quoteIdentifier('value') . ' FROM ' . $platform->quoteIdentifier('settings') . ' WHERE ' . $platform->quoteIdentifier('key') . ' = ' . $platform->quoteValue('ini-cache') . ' AND ' . $platform->quoteIdentifier('type') . ' = ' . $platform->quoteValue('ini-cache') . ' LIMIT 1 '); $this->config = array(); $result = $query->execute(); if ($result->getAffectedRows() > 0) { foreach ($result as $cache) { $this->config = ArrayUtils::merge($this->config, (array) unserialize($cache['value'])); } } else { $query = $this->dbAdapter->query(' SELECT ' . $platform->quoteIdentifier('key') . ', ' . $platform->quoteIdentifier('value') . ' FROM ' . $platform->quoteIdentifier('settings') . ' WHERE ' . $platform->quoteIdentifier('type') . ' = ' . $platform->quoteValue('ini') . ' '); foreach ($query->execute() as $pair) { $key = (string) $pair['key']; $value = (string) $pair['value']; $entry = array(); $curr =& $entry; foreach (explode('.', $key) as $sub) { $curr[$sub] = null; $curr =& $curr[$sub]; } $curr = $value; $this->config = ArrayUtils::merge($this->config, $entry); } $query = $this->dbAdapter->query(' INSERT INTO ' . $platform->quoteIdentifier('settings') . ' ( ' . $platform->quoteIdentifier('key') . ', ' . $platform->quoteIdentifier('value') . ', ' . $platform->quoteIdentifier('type') . ' ) VALUES ( ' . $driver->formatParameterName('key') . ', ' . $driver->formatParameterName('value') . ', ' . $driver->formatParameterName('type') . ' ) '); $query->execute(array('key' => 'ini-cache', 'value' => serialize($this->config), 'type' => 'ini-cache')); } $this->dbAdapter = null; return $this->config; }
public function selectCategoryOptions() { $adapter = new Adapter(array('driver' => 'mysqli', 'host' => 'localhost', 'port' => '3306', 'dbname' => 'zndemo', 'username' => 'root', 'password' => '')); $result = $adapter->getDriver()->getConnection()->execute('select id,name from categories where status=1'); $selectData = array(0 => '--Select Category--'); foreach ($result as $res) { $selectData[$res['id']] = $res['name']; } return $selectData; }
/** * Create source from adapter * * @param Adapter $adapter * @return Source\InformationSchemaMetadata */ protected function createSourceFromAdapter(Adapter $adapter) { switch ($adapter->getPlatform()->getName()) { case 'MySQL': case 'SQLServer': return new Source\InformationSchemaMetadata($adapter); case 'SQLite': return new Source\SqliteMetadata($adapter); } throw new \Exception('cannot create source from adapter'); }
public function __construct(Adapter $adapter) { $this->adapter = $adapter; $platform = $adapter->getPlatform(); switch (strtolower($platform->getName())) { case 'sqlserver': $platform = new SqlServer\SqlServer(); $this->decorators = $platform->decorators; break; default: } }
/** * */ public function setUpMockedAdapter() { $this->mockedDbAdapterDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface'); $this->mockedDbAdapterPlatform = $this->getMock('\\Zend\\Db\\Adapter\\Platform\\PlatformInterface', array()); $this->mockedDbAdapterStatement = $this->getMock('\\Zend\\Db\\Adapter\\Driver\\StatementInterface', array()); $this->mockedDbAdapterPlatform->expects($this->any())->method('getName')->will($this->returnValue('null')); $this->mockedDbAdapter = $this->getMockBuilder('\\Zend\\Db\\Adapter\\Adapter')->setConstructorArgs(array($this->mockedDbAdapterDriver, $this->mockedDbAdapterPlatform))->getMock(array('getPlatform')); $this->mockedDbAdapter->expects($this->any())->method('getPlatform')->will($this->returnValue($this->mockedDbAdapterPlatform)); $this->mockedDbSql = $this->getMockBuilder('\\Zend\\Db\\Sql\\Sql')->setConstructorArgs(array($this->mockedDbAdapter))->setMethods(array('prepareStatementForSqlObject'))->getMock(); $this->mockedDbSql->expects($this->any())->method('prepareStatementForSqlObject')->will($this->returnValue($this->mockedDbAdapterStatement)); $this->mockedDbSqlPlatform = $this->getMockBuilder('\\Zend\\Db\\Sql\\Platform\\Platform')->setConstructorArgs(array($this->mockedDbAdapter))->getMock(); }
public function save(Queue $queue) { if ($queue->getId()) { $query = $this->dbAdapter->query('UPDATE `queues` SET `name` = :name WHERE `id = :id`'); $query->execute($queue->getArrayCopy()); } else { $query = $this->dbAdapter->query("INSERT INTO `queues` (`name`) VALUES (:name)"); $query->execute(['name' => $queue->getName()]); $queue->setId($this->dbAdapter->getDriver()->getLastGeneratedValue()); } return $queue; }
protected function processOffset(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null) { if ($this->offset === null) { return null; } if ($adapter) { $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER); return array($adapter->getDriver()->formatParameterName('offset')); } else { return array($this->offset); } }
/** * Automatically create source from adapter * * @throws Exception\UnsupportedDriverException * @param \Zend\Db\Adapter\Adapter $adapter * @param string $schema database schema to use or null to current schema defined by the adapter * @return \Soluble\Db\Metadata\Source\AbstractSource */ protected function createSourceFromAdapter(Adapter $adapter, $schema = null) { $adapter_name = strtolower($adapter->getPlatform()->getName()); switch ($adapter_name) { case 'mysql': $source = new Source\Mysql\InformationSchema($adapter, $schema); break; default: throw new Exception\UnsupportedDriverException("Currently only MySQL is supported, driver set '{$adapter_name}'"); } return $source; }
/** * Create db adapter service * * @param ServiceLocatorInterface $serviceLocator * @return Adapter */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $result = new Adapter($config['db']); if (defined('SCPPER_DEBUG')) { $profiler = new \Zend\Db\Adapter\Profiler\Profiler(); $result->setProfiler($profiler); if ($result->getPlatform()->getName() === 'MySQL') { $result->query('SET SESSION query_cache_type=0;', Adapter::QUERY_MODE_EXECUTE); } } return $result; }
/** * @return $this */ public function reset() { $this['adapter'] = $this->share(function () { if (!$this->getConfigDb() instanceof Config) { throw new BaseException("DatabaseProvider is not configured"); } try { $adapter = new Adapter(array('driver' => $this->getConfigDb()->getDriver(), 'database' => $this->getConfigDb()->getDb(), 'username' => $this->getConfigDb()->getUser(), 'password' => $this->getConfigDb()->getPass(), 'hostname' => $this->getConfigDb()->getHost())); if (is_array($this->getConfigDb()->getInitialQueries())) { foreach ($this->getConfigDb()->getInitialQueries() as $query) { $adapter->query($query, array()); } } return $adapter; } catch (ExceptionInterface $e) { throw new BaseException('Error while connecting to db', 0, $e); } }); $this['value_storage'] = $this->share(function () { return new ValueStorage($this->getCache()); }); $this['db'] = $this->share(function () { return new DatabaseProvider($this['adapter']); }); $this['cacheMemory'] = $this->share(function () { $cache = new CacheProvider(); $cache->init($this['cache_config']); $cache->connect(); return $cache; }); $this['cacheSession'] = $this->share(function () { return new Session(); }); $this['identityMap'] = $this->share(function () { return new IdentityMap(new IdentityMapStorage(), new IdentityMapStorage(), new IdentityMapStorage()); }); $this['transaction'] = $this->share(function () { $transaction = new TransactionAggregator(); foreach ($this['transaction_engines'] as $engine) { $transaction->registerTransactionEngine($engine); } return $transaction; }); $this['transaction_engines'] = $this->share(function () { return [$this->getDb(), $this->getCache()->getAdapter(), $this->getIdentityMap()]; }); $this['repository'] = $this->share(function () { return new Repository(); }); return $this; }
/** * Create db adapter service * * @param ServiceLocatorInterface $serviceLocator * @return Adapter */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $adapter = new Adapter($config['db']); $authStorage = $serviceLocator->get('Sundew\\AuthStorage'); $user = array(); if (!$authStorage->isEmpty()) { $user = $authStorage->read(); } $fileName = 'Query' . date('Ymd') . '.log'; $logger = new SundewLogger($fileName, $user); $adapter->setProfiler($logger); return $adapter; }
private function createTable($query) { try { $this->dbAdapter->query($query, DbAdapter::QUERY_MODE_EXECUTE); } catch (\PDOException $e) { if (strpos($e->getMessage(), 'table or view already exists') === false) { echo $e->getMessage() . PHP_EOL; exit(1); } } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL; exit(1); } }
public function reinstall($config) { $adapter = new Adapter($config); $adapter->createStatement('DROP DATABASE IF EXISTS `' . $config['database'] . '`')->execute(); $config_file = 'config/autoload/local.php'; $old_config = array(); if (file_exists($config_file)) { $old_config = (include $config_file); unset($old_config['db']); unlink($config_file); $writer = new ConfigWriter(); $writer->toFile($config_file, new Config($old_config)); } $this->install($config); }
public function save(User $user) { //select $sql1 = 'select max(userID) from user'; $statement = $this->dbAdapter->query($sql1); $result = $statement->execute(); $row = $result->current(); // Debug::dump($row ); $user->setUserID($row['max(userID)'] + 1); //insert $defaultfaceimgpath = '/data/face/defaultfaceimg.png'; $sql = 'insert into user(userID,username,upassword,schoolID,faceimgpath) values(' . $user->getUserID() . ',"' . $user->getUsername() . '","' . $user->getUpassword() . '","' . $user->getSchoolID() . '","' . $defaultfaceimgpath . '")'; // echo $sql; $this->dbAdapter->query($sql, Adapter::QUERY_MODE_EXECUTE); }
/** * @param array|\Zend\Db\Adapter\Driver\DriverInterface $config * @throws UnsupportedDriverException * @return \Zend\Db\Adapter\Adapter */ public static function factory($config) { $platform = new SphinxQL(); $adapter = new ZendDBAdapter($config, $platform); $driver = $adapter->getDriver(); // Check driver if ($driver instanceof ZendPdoDriver && $driver->getDatabasePlatformName(ZendPdoDriver::NAME_FORMAT_CAMELCASE) == 'Mysql') { $driver->registerStatementPrototype(new PdoStatement()); } elseif (!$driver instanceof ZendMysqliDriver) { $class = get_class($driver); throw new UnsupportedDriverException($class . ' not supported. Use Zend\\Db\\Adapter\\Driver\\Pdo\\Pdo or Zend\\Db\\Adapter\\Driver\\Mysqli\\Mysqli'); } $platform->setDriver($adapter->getDriver()); return $adapter; }
/** * Autenticates the user * @return \Zend\Authentication\Result */ public function authenticate() { extract($this->db->query(' SELECT COUNT(`username`) as isAuthenticated FROM `login` WHERE (SELECT `active` FROM `profile` WHERE `login`.`profile_id`=`profile`.`id`) = 1 AND `username`="' . addslashes($this->username) . '" AND `password`="' . addslashes(md5($this->password)) . '" ', \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE)->current()->getArrayCopy()); if ($isAuthenticated > 0) { $code = \Zend\Authentication\Result::SUCCESS; } else { $code = \Zend\Authentication\Result::FAILURE; } return new \Zend\Authentication\Result($code, $_REQUEST['username']); }
/** * @return void */ public function indexAction() { // 'Found SocketRresonse queue' $this->messages = array(); $this->checkDb(); $this->checkRabbit(); $this->getQueues(); $res = array(); if (is_file('/var/www/htdocs/logs/sqlite.db')) { $dbconfig = array('driver' => 'Pdo', 'dsn' => 'sqlite:/var/www/htdocs/logs/sqlite.db'); $db = new Adapter($dbconfig); $res = $db->query('select id,message,priority,datetime(timestamp) as timestamp ,' . 'extra_0,extra_1 from log_table order by datetime(timestamp) desc limit 20')->execute(); } return new ViewModel(array('message' => $this->messages, 'errorlog' => $res)); }
/** * {@inheritDoc} */ protected function createDriver($parameters) { if (is_array($parameters) && isset($parameters['driver']) && isset($parameters['pdodriver']) && is_string($parameters['driver']) && is_string($parameters['pdodriver']) && strtolower($parameters['driver']) == 'pdo' && strtolower($parameters['pdodriver']) == 'pgsql') { return new Pdo(new Driver\Pdo\PgsqlConnection($parameters), new Driver\Pdo\Statement()); } return parent::createDriver($parameters); }
protected function createSourceFromAdapter(Adapter $adapter) { switch ($adapter->getPlatform()->getName()) { case 'MySQL': return new Source\MysqlMetadata($adapter); case 'SQLServer': return new Source\SqlServerMetadata($adapter); case 'SQLite': return new Source\SqliteMetadata($adapter); case 'PostgreSQL': return new Source\PostgresqlMetadata($adapter); case 'Oracle': return new Source\OracleMetadata($adapter); } throw new \Exception('cannot create source from adapter'); }
/** * Drops the database table for session data * * @return void */ protected function dropTable() { if (!$this->adapter) { return; } $this->adapter->query('DROP TABLE sessions', Adapter::QUERY_MODE_EXECUTE); }
/** * Load constraint references * * @param string $schema * @param string $database * @return type */ protected function loadConstraintReferences($schema, $database) { /** @var $platform \Zend\Db\Adapter\PlatformInterface */ $platform = $this->adapter->getPlatform(); $quoteIdentifierForWalk = function (&$c) use($platform) { $c = $platform->quoteIdentifierInFragment($c); }; $quoteSelectList = function (array $identifierList) use($platform, $quoteIdentifierForWalk) { array_walk($identifierList, $quoteIdentifierForWalk); return implode(', ', $identifierList); }; // target: CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UPDATE_RULE, DELETE_RULE, REFERENCE_CONSTRAINT_NAME if ($platform->getName() == 'MySQL') { $sql = 'SELECT ' . $quoteSelectList(array('RC.CONSTRAINT_NAME', 'RC.UPDATE_RULE', 'RC.DELETE_RULE', 'RC.TABLE_NAME', 'CK.REFERENCED_TABLE_NAME', 'CK.REFERENCED_COLUMN_NAME')) . ' FROM ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC') . ' INNER JOIN ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.KEY_COLUMN_USAGE CK') . ' ON ' . $platform->quoteIdentifierInFragment('RC.CONSTRAINT_NAME') . ' = ' . $platform->quoteIdentifierInFragment('CK.CONSTRAINT_NAME'); } else { $sql = 'SELECT ' . $quoteSelectList(array('RC.CONSTRAINT_NAME', 'RC.UPDATE_RULE', 'RC.DELETE_RULE', 'TC1.TABLE_NAME', 'CK.TABLE_NAME AS REFERENCED_TABLE_NAME', 'CK.COLUMN_NAME AS REFERENCED_COLUMN_NAME')) . ' FROM ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC') . ' INNER JOIN ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC1') . ' ON ' . $platform->quoteIdentifierInFragment('RC.CONSTRAINT_NAME') . ' = ' . $platform->quoteIdentifierInFragment('TC1.CONSTRAINT_NAME') . ' INNER JOIN ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC2') . ' ON ' . $platform->quoteIdentifierInFragment('RC.UNIQUE_CONSTRAINT_NAME') . ' = ' . $platform->quoteIdentifierInFragment('TC2.CONSTRAINT_NAME') . ' INNER JOIN ' . $platform->quoteIdentifierInFragment('INFORMATION_SCHEMA.KEY_COLUMN_USAGE CK') . ' ON ' . $platform->quoteIdentifierInFragment('TC2.CONSTRAINT_NAME') . ' = ' . $platform->quoteIdentifierInFragment('CK.CONSTRAINT_NAME'); } if ($schema != '__DEFAULT_SCHEMA__') { $sql .= ' AND ' . $platform->quoteIdentifierInFragment('RC.CONSTRAINT_SCHEMA') . ' = ' . $platform->quoteValue($schema); } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); $constraintRefData = array(); foreach ($results->toArray() as $row) { $constraintRefData[] = array_change_key_case($row, CASE_LOWER); } $this->prepareDataHeirarchy($database, $schema, array('constraints', 'keys')); $this->data[$database][$schema]['constraints']['references'] = $constraintRefData; }