diff --git a/VERSION.txt b/VERSION.txt index 236b4b1b0..be81f57aa 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -0.10.3.1131_alpha \ No newline at end of file +0.10.3.1307_alpha \ No newline at end of file diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index db8160f59..f2f051c63 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -657,6 +657,19 @@ class Model extends Object return $this->_tableInfo->findIn('name', $name); } +/** + * Initializes the model for writing a new record + * + * @return boolean True on success + */ + function create () + { + $this->id = false; + unset($this->data); + $this->data = array(); + } + + /** * Returns a list of fields from the database * @@ -1042,8 +1055,8 @@ class Model extends Object $oneToOneConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'}); $oneToOneOrder = $this->{$model}->{$this->currentModel.'_order'}; - $joins[] = "LEFT JOIN {$this->{$model}->table} AS $alias ON - $alias.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->name}.id" + $joins[] = "LEFT JOIN {$this->{$model}->table} AS `$alias` ON + `$alias`.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->name}.id" .($oneToOneConditions? " WHERE {$oneToOneConditions}":null) .($oneToOneOrder? " ORDER BY {$oneToOneOrder}": null); } @@ -1069,7 +1082,7 @@ class Model extends Object $belongsToOtherConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'}); $belongsToOtherOrder = $this->{$model}->{$this->currentModel.'_order'}; - $joins[] = "LEFT JOIN {$this->{$model}->table} AS $alias ON {$this->name}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = $alias.id" + $joins[] = "LEFT JOIN {$this->{$model}->table} AS `$alias` ON {$this->name}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = `$alias`.id" .($belongsToOtherConditions? " WHERE {$belongsToOtherConditions}":null) .($belongsToOtherOrder? " ORDER BY {$belongsToOtherOrder}": null); } @@ -1087,7 +1100,7 @@ class Model extends Object : ''; $sql = "SELECT " .join(', ', $f) - ." FROM {$this->table} AS {$this->name} {$joins}" + ." FROM {$this->table} AS `{$this->name}` {$joins}" .($conditions? " WHERE {$conditions}":null) .($order? " ORDER BY {$order}": null) .$limit_str; @@ -1145,7 +1158,7 @@ class Model extends Object $oneToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'}); $oneToManyOrder = $this->{$model}->{$this->currentModel.'_order'}; - $tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS {$this->{$model}->name} + $tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS `{$this->{$model}->name}` WHERE ({$this->{$model}->{$this->currentModel.'_foreignkey'}}) = '{$value2['id']}'" .($oneToManyConditions? " WHERE {$oneToManyConditions}":null) .($oneToManyOrder? " ORDER BY {$oneToManyOrder}": null); @@ -1227,12 +1240,12 @@ class Model extends Object $manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'}); $manyToManyOrder = $this->{$model}->{$this->currentModel.'_order'}; - $tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS {$this->{$model}->name} + $tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS `{$this->{$model}->name}` JOIN {$this->{$model}->{$this->currentModel.'_jointable'}} ON {$this->{$model}->{$this->currentModel.'_jointable'}}. {$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]' AND {$this->{$model}->{$this->currentModel.'_jointable'}}. - {$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = {$this->{$model}->name} .id" + {$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = `{$this->{$model}->name}` .id" .($manyToManyConditions? " WHERE {$manyToManyConditions}":null) .($manyToManyOrder? " ORDER BY {$manyToManyOrder}": null); @@ -1298,9 +1311,9 @@ class Model extends Object { foreach ($this->tableToModel as $key1 => $value1) { - if (isset($data[$key][Inflector::singularize($key1)])) + if (isset($data[$key][$key1])) { - $newData[$key][$value1] = $data[$key][Inflector::singularize($key1)]; + $newData[$key][$value1] = $data[$key][$key1]; } } } diff --git a/cake/libs/object.php b/cake/libs/object.php index 440bc0c19..85fabf424 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -114,7 +114,6 @@ class Object { $extra['render'] = 1; } - //$extra = array_merge($extra, array('bare'=>1)); $dispatcher =& new Dispatcher(); return $dispatcher->dispatch($url, $extra); } diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index a24183f90..eb3d6c949 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -159,7 +159,7 @@ class AjaxHelper extends Helper } else { - $html_options['onclick'] = $this->remoteFunction($options); + $html_options['onclick'] = $this->remoteFunction($options) . " return false;"; return $this->Html->link($title, $href, $html_options); } } diff --git a/cake/libs/view/templates/layouts/default.thtml b/cake/libs/view/templates/layouts/default.thtml index 4961c51fa..26692acfd 100644 --- a/cake/libs/view/templates/layouts/default.thtml +++ b/cake/libs/view/templates/layouts/default.thtml @@ -48,7 +48,7 @@ <div id="pb-cake"> © 2005 CakePHP :: <a href="https://trac.cakephp.org/wiki/Authors">CakePHP Developers and Authors</a> - <p>CakePHP version 0.10.3.1301_alpha</p> + <p>CakePHP version 0.10.3.1307_alpha</p> <a href="http://www.cakephp.org/" target="_new" class="simple"> <?php echo $html->image('cake.power.png', array('alt'=>"CakePHP : Rapid Development Framework", 'border'=>"0"))?> </a>