1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-30 21:55:05 +03:00
kohana-migrations/classes/Minion/Migration/Database.php
Evan Purkhiser bc28977d65 Cleanup coding style to conform to Kohana CS
- Added variable names to just about all @param tags
 - Ensured proper alignment in doc block comments
 - Ensured proper file spacing and trimmed all trailing whitespace
 - Corrected improper languge construct formats (eg if () not if())
 - Corrected some assignment operator alignment
 - A few spelling corrections
 - All classes pass `phpcs --Standard=Kohana` (asside from tests)
2012-10-24 04:08:09 -04:00

74 lines
1.5 KiB
PHP

<?php defined('SYSPATH') OR die('No direct script access.');
/**
* A faux database connection for doing dry run migrations
*/
class Minion_Migration_Database extends Database_MySQL {
/**
* Creates a disposable instance of the faux connection
*
* @param string $db_group The database group to use
* @param array $config Config for the underlying DB connection
* @return Minion_Migration_Database
*/
public static function faux_instance($db_group = NULL, array $config = NULL)
{
if ($config === NULL)
{
if ($db_group === NULL)
{
$db_group = Database::$default;
}
$config = Kohana::$config->load('database')->$db_group;
}
return new Minion_Migration_Database('__minion_faux', $config);
}
/**
* The query stack used to store queries
* @var array
*/
protected $_queries = array();
/**
* Gets the stack of queries that have been executed
*
* @return array
*/
public function get_query_stack()
{
return $this->_queries;
}
/**
* Resets the query stack to an empty state and returns the queries
*
* @return array Array of SQL queries that would've been executed
*/
public function reset_query_stack()
{
$queries = $this->_queries;
$this->_queries = array();
return $queries;
}
/**
* Appears to allow calling script to execute an SQL query, but merely logs
* it and returns NULL
*
* @return NULL
*/
public function query($type, $sql, $as_object = FALSE, array $params = NULL)
{
$this->_queries[] = $sql;
return NULL;
}
}