updating trunk with bug fixes and other modifications

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@737 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-08-28 16:33:50 +00:00
parent 4c5e5ec9a2
commit 7c7a2151ab
4 changed files with 48 additions and 22 deletions

View file

@ -10,17 +10,29 @@
$otherModelObject = $registry->getObject($value['model']);
$displayField = $otherModelObject->getDisplayField();
$displayText = $data[$value['model']][ $displayField ];
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelName][ $field ] )."</dd>";
} else {
// this is just a plain old field.
if( !empty($data[$modelName][$field]) )
{
echo "<dd>".$data[$modelName][$field]."</dd>";
} else {
echo "<dd>&nbsp;</dd>";
}
if( !empty($data[$modelName][$field]))
{
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelName][ $field ] )."</dd>";
}
else
{
echo "<dd>&nbsp;</dd>";
}
}
else
{
// this is just a plain old field.
if( !empty($data[$modelName][$field]))
{
echo "<dd>".$data[$modelName][$field]."</dd>";
}
else
{
echo "<dd>&nbsp;</dd>";
}
}
}
}
?>
</dl>
@ -47,14 +59,14 @@
list($table, $field, $value) = $relation;
$otherModelName = Inflector::singularize($table);
echo "<div class='related'><H2>Related ".Inflector::humanize($otherModelName)."</H2>";
echo "<div class='related'><H2>Related ".Inflector::humanize($otherModelName)."</H2><br/><br/>";
echo "<dl>";
if( isset($data[$otherModelName]) && is_array($data[$otherModelName]) )
{
foreach( $data[$otherModelName] as $field=>$value )
{
echo "<dt>".Inflector::humanize($field)."</dt>";
if( isset($value) )
if( !empty($value) )
{
echo "<dd>".$value."</dd>";
} else {
@ -64,7 +76,7 @@
}
echo "</dl>";
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($otherModelName),"/".Inflector::underscore($table)."/edit/{$data[$otherModelName]['id']}")."</li></ul>";
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($otherModelName),"/".Inflector::underscore($table)."/edit/{$data[$otherModelName]['id']}")."</li></ul></div>";
}
?>
@ -87,7 +99,7 @@
$count = 0;
$otherModelName = Inflector::singularize($table);
echo "<div class='related'><H2>Related ".Inflector::humanize($table)."</H2>";
echo "<div class='related'><H2>Related ".Inflector::humanize($table)."</H2><br/><br/>";
if( isset($data[$table]) && is_array($data[$table]) )
{
?>

View file

@ -219,9 +219,9 @@ class DBO_MySQL extends DBO
*
* @param unknown_type $results
*/
function mysqlResultSet($results)
function mysqlResultSet(&$results)
{
$this->results = $results;
$this->results =& $results;
$this->map = array();
$index = 0;
$num_fields = mysql_num_fields($results);

View file

@ -1243,8 +1243,7 @@ class Model extends Object
foreach ($this->_oneToOne as $rule)
{
list($table, $field, $value) = $rule;
$joins[] = "JOIN {$table} ON {$table}.{$field} = {$this->table}.id";
$joins[] = "LEFT JOIN {$table} ON {$table}.{$field} = {$this->table}.id";
}
}
@ -1294,9 +1293,10 @@ class Model extends Object
foreach ($value1 as $key2 => $value2)
{
$oneToManySelect[$table] = $this->db->all("SELECT * FROM {$table} WHERE ($field) = '{$value2['id']}'");
if( is_array($oneToManySelect[$table]) && ($oneToManySelect[$table] != null))
if( !empty($oneToManySelect[$table]) && is_array($oneToManySelect[$table]))
{
$newKey = Inflector::singularize($table);
$newKey = Inflector::singularize($table);
foreach ($oneToManySelect[$table] as $key => $value)
{
$oneToManySelect1[$table][$key] = $value[$newKey];
@ -1304,6 +1304,7 @@ class Model extends Object
$merged = array_merge_recursive($data[$count],$oneToManySelect1);
$newdata[$count] = $merged;
unset( $oneToManySelect[$table] );
}
if(!empty($newdata[$count]))
@ -1311,6 +1312,7 @@ class Model extends Object
$original[$count] = $newdata[$count];
}
}
$count++;
}
$this->joinedHasMany[] = new NeatArray($this->db->fields($table));
@ -1344,7 +1346,8 @@ class Model extends Object
AND {$joineTable}.{$JoinKey2} = {$table} .id";
$manyToManySelect[$table] = $this->db->all($tmpSQL);
}
if( is_array($manyToManySelect[$table]) && ($manyToManySelect[$table] != null))
if( !empty($manyToManySelect[$table]) && is_array($manyToManySelect[$table]))
{
$newKey = Inflector::singularize($table);
foreach ($manyToManySelect[$table] as $key => $value)
@ -1354,7 +1357,9 @@ class Model extends Object
$merged = array_merge_recursive($data[$count],$manyToManySelect1);
$newdata[$count] = $merged;
unset( $manyToManySelect[$table] );
}
if(!empty($newdata[$count]))
{
@ -1372,7 +1377,7 @@ class Model extends Object
$data = $original;
}
}
return $data;
}

View file

@ -12,6 +12,9 @@ font-size:2.1em;
color: #69c;
}
h2 {
margin-top:5px;
display:block;
float:left;
font-size:1.7em;
color: #383;
clear: both;
@ -144,6 +147,12 @@ table tr.altRow td {
background: #EBF4FD;
}
div.related {
display:block;
float:left;
clear:both;
}
dl {
line-height:2em;
margin:1em;