Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
BUG: Fixing issue with recursive save
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Jomier committed Mar 23, 2011
1 parent c8bd8ac commit 518ffe2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/models/pdo/BitstreamModel.php
Expand Up @@ -11,7 +11,7 @@ public function save($dao)
$stack=debug_backtrace();
if($stack[1]['class']=="ItemRevisionModel"&&$stack[1]['function']=='addBitstream')
{
return $this->database->save($dao);
return parent::save($dao);
}
throw new Zend_Exception(" Do not use, use method addBitstream in ItemRevision Model.");
}//end Save
Expand Down
2 changes: 1 addition & 1 deletion core/models/pdo/FeedModel.php
Expand Up @@ -297,7 +297,7 @@ function delete($feeDao)
{
$this->database->removeLink('communities', $feeDao, $c);
}
return $this->delete($feeDao);
return parent::delete($feeDao);
} // end delete

} // end class
Expand Down
55 changes: 54 additions & 1 deletion library/MIDAS/models/MIDASDatabaseCassandra.php
Expand Up @@ -85,7 +85,60 @@ public function delete($dao)
} // end function delete



/**
* @method public get()
* Generic get function. You can define custom function.
* @param $var name of the element we want to get
* @param $key of the table
* @return value
*/
public function getValue($var, $key, $dao)
{
if (!isset($this->_mainData[$var]))
{
throw new Zend_Exception("Database Cassandra " . $this->_name . ": var $var is not defined here.");
}

if (method_exists($this, 'get' . ucfirst($var)))
{
return call_user_func('get' . ucfirst($var), $key, $var);
}
else if ($this->_mainData[$var]['type'] == MIDAS_DATA && $key!=null)
{
/*$result = $this->fetchRow($this->select()->where($this->_key . ' = ?', $key));
if (!isset($result->$var))
{
return null;
}
return $result->$var;*/
}
else if ($this->_mainData[$var]['type'] == MIDAS_ONE_TO_MANY)
{
require_once BASE_PATH.'/library/MIDAS/models/ModelLoader.php';
$this->ModelLoader = new MIDAS_ModelLoader();
$model = $this->ModelLoader->loadModel($this->_mainData[$var]['model']);
if(!$dao->get($this->_mainData[$var]['parent_column']))
{
throw new Zend_Exception($this->_mainData[$var]['parent_column']. " is not defined in the dao: ".get_class($dao));
}
//return $model->__call("findBy" . ucfirst($this->_mainData[$var]['child_column']), array($dao->get($this->_mainData[$var]['parent_column'])));
}
else if ($this->_mainData[$var]['type'] == MIDAS_MANY_TO_ONE)
{
require_once BASE_PATH.'/library/MIDAS/models/ModelLoader.php';
$this->ModelLoader = new MIDAS_ModelLoader();
$model = $this->ModelLoader->loadModel($this->_mainData[$var]['model']);
//return $model->__call("getBy" . ucfirst($this->_mainData[$var]['child_column']), array($dao->get($this->_mainData[$var]['parent_column'])));
}
else if ($this->_mainData[$var]['type'] == MIDAS_MANY_TO_MANY)
{
//return $this->getLinkedObject($var, $dao);
}
else
{
throw new Zend_Exception('Unable to load data type ' . $var);
}
}

} // end class MIDASDatabaseCassandra
?>
1 change: 1 addition & 0 deletions library/MIDAS/models/MIDASDatabaseInterface.php
Expand Up @@ -3,6 +3,7 @@ interface MIDASDatabaseInterface
{
public function save($dao);
public function delete($dao);
public function getValue($var, $key, $dao);

} // end interface
?>
2 changes: 1 addition & 1 deletion library/MIDAS/models/MIDASDatabasePdo.php
Expand Up @@ -55,7 +55,7 @@ public function getValue($var, $key, $dao)
{
if (!isset($this->_mainData[$var]))
{
throw new Zend_Exception("Model PDO " . $this->_name . ": var $var is not defined here.");
throw new Zend_Exception("Database PDO " . $this->_name . ": var $var is not defined here.");
}
if (method_exists($this, 'get' . ucfirst($var)))
{
Expand Down

0 comments on commit 518ffe2

Please sign in to comment.