1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-07-02 22:55:03 +03:00
kohana-migrations/classes/Minion/Migration/Database.php

74 lines
1.5 KiB
PHP
Raw Normal View History

<?php defined('SYSPATH') OR die('No direct script access.');
2010-12-29 06:30:25 +02:00
/**
* 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
2010-12-29 06:30:25 +02:00
* @return Minion_Migration_Database
*/
public static function faux_instance($db_group = NULL, array $config = NULL)
2010-12-29 06:30:25 +02:00
{
if ($config === NULL)
{
if ($db_group === NULL)
{
$db_group = Database::$default;
}
2011-06-27 22:57:21 +03:00
$config = Kohana::$config->load('database')->$db_group;
}
return new Minion_Migration_Database('__minion_faux', $config);
2010-12-29 06:30:25 +02:00
}
/**
* The query stack used to store queries
* @var array
*/
protected $_queries = array();
/**
* Gets the stack of queries that have been executed
*
2010-12-29 06:30:25 +02:00
* @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
2010-12-29 06:30:25 +02:00
*/
public function reset_query_stack()
{
$queries = $this->_queries;
2010-12-29 06:30:25 +02:00
$this->_queries = array();
return $queries;
2010-12-29 06:30:25 +02:00
}
/**
* Appears to allow calling script to execute an SQL query, but merely logs
2010-12-29 06:30:25 +02:00
* it and returns NULL
*
* @return NULL
*/
public function query($type, $sql, $as_object = FALSE, array $params = NULL)
{
$this->_queries[] = $sql;
return NULL;
}
2010-12-29 06:30:25 +02:00
}