mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
[1306]
Author: phpnut Date: 8:09:29 PM, Tuesday, November 01, 2005 [1304] Author: nate Date: 5:31:39 PM, Tuesday, November 01, 2005 Message: Fixed Ticket #77 [1295] Author: nate Date: 1:51:45 PM, Tuesday, November 01, 2005 Message: Added create() method to initialize model for new record [1305] Author: phpnut Date: 7:28:30 PM, Tuesday, November 01, 2005 Message: Fixed bug in the Model::findBySql(); Added fix for Ticket #111 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1307 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3f4855fb53
commit
1560819c38
5 changed files with 25 additions and 13 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
0.10.3.1131_alpha
|
||||
0.10.3.1307_alpha
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ class Object
|
|||
{
|
||||
$extra['render'] = 1;
|
||||
}
|
||||
//$extra = array_merge($extra, array('bare'=>1));
|
||||
$dispatcher =& new Dispatcher();
|
||||
return $dispatcher->dispatch($url, $extra);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue