mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 18:12:40 +00:00
Merge branch '1.2' of dev@code.cakephp.org:cakephp into 1.2
This commit is contained in:
commit
12e0652943
7 changed files with 396 additions and 23 deletions
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Command-line database management utility to automate programmer chores.
|
||||
*
|
||||
|
@ -9,20 +8,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.console.libs
|
||||
* @since CakePHP(tm) v 1.2.0.5550
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('File');
|
||||
|
@ -116,7 +112,7 @@ class SchemaShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
function generate() {
|
||||
$this->out('Generating Schema...');
|
||||
$this->out(__('Generating Schema...', true));
|
||||
$options = array();
|
||||
if (isset($this->params['f'])) {
|
||||
$options = array('models' => false);
|
||||
|
@ -131,7 +127,7 @@ class SchemaShell extends Shell {
|
|||
$snapshot = true;
|
||||
$result = strtolower($this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's'));
|
||||
if ($result === 'q') {
|
||||
$this->_stop();
|
||||
return $this->_stop();
|
||||
}
|
||||
if ($result === 'o') {
|
||||
$snapshot = false;
|
||||
|
@ -224,7 +220,7 @@ class SchemaShell extends Shell {
|
|||
*/
|
||||
function run() {
|
||||
if (!isset($this->args[0])) {
|
||||
$this->err('command not found');
|
||||
$this->err(__('Command not found', true));
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
|
@ -271,8 +267,8 @@ class SchemaShell extends Shell {
|
|||
$this->__update($Schema, $table);
|
||||
break;
|
||||
default:
|
||||
$this->err(__('command not found', true));
|
||||
$this->_stop();
|
||||
$this->err(__('Command not found', true));
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -281,7 +277,7 @@ class SchemaShell extends Shell {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __create($Schema, $table = null) {
|
||||
function __create(&$Schema, $table = null) {
|
||||
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
||||
|
||||
$drop = $create = array();
|
||||
|
@ -304,7 +300,7 @@ class SchemaShell extends Shell {
|
|||
$this->out(array_keys($drop));
|
||||
|
||||
if ('y' == $this->in(__('Are you sure you want to drop the table(s)?', true), array('y', 'n'), 'n')) {
|
||||
$this->out('Dropping table(s).');
|
||||
$this->out(__('Dropping table(s).', true));
|
||||
$this->__run($drop, 'drop', $Schema);
|
||||
}
|
||||
|
||||
|
@ -312,7 +308,7 @@ class SchemaShell extends Shell {
|
|||
$this->out(array_keys($create));
|
||||
|
||||
if ('y' == $this->in(__('Are you sure you want to create the table(s)?', true), array('y', 'n'), 'y')) {
|
||||
$this->out('Creating table(s).');
|
||||
$this->out(__('Creating table(s).', true));
|
||||
$this->__run($create, 'create', $Schema);
|
||||
}
|
||||
|
||||
|
@ -324,11 +320,15 @@ class SchemaShell extends Shell {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __update($Schema, $table = null) {
|
||||
function __update(&$Schema, $table = null) {
|
||||
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
||||
|
||||
$this->out('Comparing Database to Schema...');
|
||||
$Old = $this->Schema->read();
|
||||
$this->out(__('Comparing Database to Schema...', true));
|
||||
$options = array();
|
||||
if (isset($this->params['f'])) {
|
||||
$options['models'] = false;
|
||||
}
|
||||
$Old = $this->Schema->read($options);
|
||||
$compare = $this->Schema->compare($Old, $Schema);
|
||||
|
||||
$contents = array();
|
||||
|
@ -361,7 +361,7 @@ class SchemaShell extends Shell {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __run($contents, $event, $Schema) {
|
||||
function __run($contents, $event, &$Schema) {
|
||||
if (empty($contents)) {
|
||||
$this->err(__('Sql could not be run', true));
|
||||
return;
|
||||
|
@ -369,7 +369,7 @@ class SchemaShell extends Shell {
|
|||
Configure::write('debug', 2);
|
||||
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
||||
$db->fullDebug = true;
|
||||
|
||||
|
||||
foreach ($contents as $table => $sql) {
|
||||
if (empty($sql)) {
|
||||
$this->out(sprintf(__('%s is up to date.', true), $table));
|
||||
|
@ -403,7 +403,8 @@ class SchemaShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
$this->out("The Schema Shell generates a schema object from \n\t\tthe database and updates the database from the schema.");
|
||||
$this->out("The Schema Shell generates a schema object from");
|
||||
$this->out("the database and updates the database from the schema.");
|
||||
$this->hr();
|
||||
$this->out("Usage: cake schema <command> <arg1> <arg2>...");
|
||||
$this->hr();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue