Merging fixes into the trunk.

Revision: [2654]
Refactored the Object::cakeError()

Revision: [2653]
Adding check for custom error class in app/.
Added check for AppController::appError(); will be called if this method 
is in AppController.

Revision: [2652]
Adding fix for Ticket #704

Revision: [2650]
Fixing scaffold CSS

Revision: [2648]
Adding fix for Ticket #717

Revision: [2647]
Adding fix for Ticket #718

git-svn-id: https://svn.cakephp.org/repo/trunk/cake/1.x.x.x@2685 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-05-01 23:50:20 +00:00
parent e385b666dd
commit 75130a2187
6 changed files with 38 additions and 78 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
1.0.0.2642
1.0.0.2685

View file

@ -75,26 +75,23 @@ table {
width: 100%;
background-color: #fff;
border: 1px solid #333;
border-collapse: collapse;
clear:both;
margin: 0 0 2em 0;
white-space: normal;
}
tbody {
height: 400px;
overflow: auto;
}
th {
border: 1px solid #666;
background-color: #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #666;
border-bottom: 1px solid #666;
text-align: center;
padding:3px;
border-bottom: 1px solid #666;
}
table tr td {
border-right: 1px solid #ccc;
padding:4px 4px;
vertical-align:top;
text-align: center;
border-bottom: 1px solid #666;
}
table tr.altRow td {
background: #f4f4f4;

View file

@ -52,17 +52,23 @@ class ErrorHandler extends Object
if ($__previousError != array($method, $messages))
{
$__previousError = array($method, $messages);
if(!class_exists('AppController'))
{
loadController(null);
}
$this->controller =& new AppController();
if(method_exists($this->controller, 'apperror'))
{
return $this->controller->appError($method, $messages);
}
}
else
{
$this->controller =& new Controller();
}
$__previousError = array($method, $messages);
if(DEBUG > 0 || $method == 'error')
{

View file

@ -400,7 +400,13 @@ class DboMysql extends DboSource
*/
function lastInsertId ($source = null)
{
return mysql_insert_id($this->connection);
$id = mysql_insert_id($this->connection);
if ($id)
{
return $id;
}
$data = $this->fetchAll('SELECT LAST_INSERT_ID() as id From '.$source);
return $data[0]['id'];
}
/**

View file

@ -608,68 +608,6 @@ class DboPostgres extends DboSource
return false;
}
}
/**
* The "C" in CRUD
*
* @param Model $model
* @param array $fields
* @param array $values
* @return boolean Success
*/
function create(&$model, $fields = null, $values = null)
{
if ($fields == null)
{
unset($fields, $values);
$fields = array_keys($model->data);
$values = array_values($model->data);
}
foreach ($fields as $field)
{
$fieldInsert[] = $this->name($field);
}
$count = 0;
foreach ($values as $value)
{
if ($value === '')
{
$columns = $model->loadInfo();
$columns = $columns->value;
foreach($columns as $col)
{
if ($col['name'] == $fields[$count])
{
$insert = $col['default'];
break;
}
}
}
if (empty($insert))
{
$insert = $this->value($value, $model->getColumnType($fields[$count]));
}
if ($insert === '\'\'')
{
unset($fieldInsert[$count]);
}
else
{
$valueInsert[] = $insert;
}
unset($insert);
$count++;
}
if($this->execute('INSERT INTO '.$model->table.' ('.join(',', $fieldInsert).') VALUES ('.join(',', $valueInsert).')'))
{
return true;
}
return false;
}
}
?>

View file

@ -157,19 +157,32 @@ class Object
}
/**
* Enter description here...
* Used to report user friendly errors.
* If there is a file app/error.php this file will be loaded
* error.php is the AppError class it should extend ErrorHandler class.
*
* @param unknown_type $method
* @param unknown_type $messages
* @return unknown
* @param string $method Method to be called in the error class (AppError or ErrorHandler classes)
* @param array $messages Message that is to be displayed by the error class
* @return error message
*/
function cakeError($method, $messages)
{
if(!class_exists('ErrorHandler'))
{
uses('error');
if(file_exists(APP.'error.php'))
{
include_once(APP.'error.php');
}
}
if(class_exists('AppError'))
{
$error = new AppError($method, $messages);
}
else
{
$error = new ErrorHandler($method, $messages);
}
return $error;
}