Skip to content

Commit

Permalink
Merge branch '1.2' of dev@code.cakephp.org:cakephp into 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 7, 2009
2 parents 6821e7c + daadac0 commit 12e0652
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 23 deletions.
41 changes: 21 additions & 20 deletions cake/console/libs/schema.php
@@ -1,5 +1,4 @@
<?php <?php
/* SVN FILE: $Id$ */
/** /**
* Command-line database management utility to automate programmer chores. * Command-line database management utility to automate programmer chores.
* *
Expand All @@ -9,20 +8,17 @@
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org) * 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 * Licensed under The MIT License
* Redistributions of files must retain the above copyright notice. * Redistributions of files must retain the above copyright notice.
* *
* @filesource * @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 * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake * @package cake
* @subpackage cake.cake.console.libs * @subpackage cake.cake.console.libs
* @since CakePHP(tm) v 1.2.0.5550 * @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 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import('File'); App::import('File');
Expand Down Expand Up @@ -116,7 +112,7 @@ function view() {
* @access public * @access public
*/ */
function generate() { function generate() {
$this->out('Generating Schema...'); $this->out(__('Generating Schema...', true));
$options = array(); $options = array();
if (isset($this->params['f'])) { if (isset($this->params['f'])) {
$options = array('models' => false); $options = array('models' => false);
Expand All @@ -131,7 +127,7 @@ function generate() {
$snapshot = true; $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')); $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') { if ($result === 'q') {
$this->_stop(); return $this->_stop();
} }
if ($result === 'o') { if ($result === 'o') {
$snapshot = false; $snapshot = false;
Expand Down Expand Up @@ -224,7 +220,7 @@ function dump() {
*/ */
function run() { function run() {
if (!isset($this->args[0])) { if (!isset($this->args[0])) {
$this->err('command not found'); $this->err(__('Command not found', true));
$this->_stop(); $this->_stop();
} }


Expand Down Expand Up @@ -271,8 +267,8 @@ function run() {
$this->__update($Schema, $table); $this->__update($Schema, $table);
break; break;
default: default:
$this->err(__('command not found', true)); $this->err(__('Command not found', true));
$this->_stop(); $this->_stop();
} }
} }
/** /**
Expand All @@ -281,7 +277,7 @@ function run() {
* *
* @access private * @access private
*/ */
function __create($Schema, $table = null) { function __create(&$Schema, $table = null) {
$db =& ConnectionManager::getDataSource($this->Schema->connection); $db =& ConnectionManager::getDataSource($this->Schema->connection);


$drop = $create = array(); $drop = $create = array();
Expand All @@ -304,15 +300,15 @@ function __create($Schema, $table = null) {
$this->out(array_keys($drop)); $this->out(array_keys($drop));


if ('y' == $this->in(__('Are you sure you want to drop the table(s)?', true), array('y', 'n'), 'n')) { 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); $this->__run($drop, 'drop', $Schema);
} }


$this->out("\n" . __('The following table(s) will be created.', true)); $this->out("\n" . __('The following table(s) will be created.', true));
$this->out(array_keys($create)); $this->out(array_keys($create));


if ('y' == $this->in(__('Are you sure you want to create the table(s)?', true), array('y', 'n'), 'y')) { 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); $this->__run($create, 'create', $Schema);
} }


Expand All @@ -324,11 +320,15 @@ function __create($Schema, $table = null) {
* *
* @access private * @access private
*/ */
function __update($Schema, $table = null) { function __update(&$Schema, $table = null) {
$db =& ConnectionManager::getDataSource($this->Schema->connection); $db =& ConnectionManager::getDataSource($this->Schema->connection);


$this->out('Comparing Database to Schema...'); $this->out(__('Comparing Database to Schema...', true));
$Old = $this->Schema->read(); $options = array();
if (isset($this->params['f'])) {
$options['models'] = false;
}
$Old = $this->Schema->read($options);
$compare = $this->Schema->compare($Old, $Schema); $compare = $this->Schema->compare($Old, $Schema);


$contents = array(); $contents = array();
Expand Down Expand Up @@ -361,15 +361,15 @@ function __update($Schema, $table = null) {
* *
* @access private * @access private
*/ */
function __run($contents, $event, $Schema) { function __run($contents, $event, &$Schema) {
if (empty($contents)) { if (empty($contents)) {
$this->err(__('Sql could not be run', true)); $this->err(__('Sql could not be run', true));
return; return;
} }
Configure::write('debug', 2); Configure::write('debug', 2);
$db =& ConnectionManager::getDataSource($this->Schema->connection); $db =& ConnectionManager::getDataSource($this->Schema->connection);
$db->fullDebug = true; $db->fullDebug = true;

foreach ($contents as $table => $sql) { foreach ($contents as $table => $sql) {
if (empty($sql)) { if (empty($sql)) {
$this->out(sprintf(__('%s is up to date.', true), $table)); $this->out(sprintf(__('%s is up to date.', true), $table));
Expand Down Expand Up @@ -403,7 +403,8 @@ function __run($contents, $event, $Schema) {
* @access public * @access public
*/ */
function help() { 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->hr();
$this->out("Usage: cake schema <command> <arg1> <arg2>..."); $this->out("Usage: cake schema <command> <arg1> <arg2>...");
$this->hr(); $this->hr();
Expand Down
6 changes: 5 additions & 1 deletion cake/libs/controller/components/email.php
Expand Up @@ -680,10 +680,14 @@ function __smtp() {
return false; return false;
} }


$httpHost = env('HTTP_HOST');

if (isset($this->smtpOptions['client'])) { if (isset($this->smtpOptions['client'])) {
$host = $this->smtpOptions['client']; $host = $this->smtpOptions['client'];
} elseif (!empty($httpHost)) {
$host = $httpHost;
} else { } else {
$host = env('HTTP_HOST'); $host = 'localhost';
} }


if (!$this->__smtpSend("HELO {$host}", '250')) { if (!$this->__smtpSend("HELO {$host}", '250')) {
Expand Down
3 changes: 3 additions & 0 deletions cake/libs/model/datasources/dbo/dbo_mssql.php
Expand Up @@ -259,6 +259,9 @@ function value($data, $column = null, $safe = false) {
if ($data === null) { if ($data === null) {
return 'NULL'; return 'NULL';
} }
if (in_array($column, array('integer', 'float', 'binary')) && $data === '') {
return 'NULL';
}
if ($data === '') { if ($data === '') {
return "''"; return "''";
} }
Expand Down
1 change: 1 addition & 0 deletions cake/libs/model/schema.php
Expand Up @@ -172,6 +172,7 @@ function load($options = array()) {
* - 'connection' - the db connection to use * - 'connection' - the db connection to use
* - 'name' - name of the schema * - 'name' - name of the schema
* - 'models' - a list of models to use, or false to ignore models * - 'models' - a list of models to use, or false to ignore models
*
* @param array $options schema object properties * @param array $options schema object properties
* @return array Array indexed by name and tables * @return array Array indexed by name and tables
* @access public * @access public
Expand Down

0 comments on commit 12e0652

Please sign in to comment.