Zend Exception Message: Cannot save a Row unless it is connected

user warning: Table 'diogomelo.ds_settings' doesn't exist query: ds_get_settings /* Anonymous : ds_get_settings */ SELECT module, type, build_mode, settings, fields FROM ds_settings WHERE module = 'nd' AND type = 'blog' AND build_mode = 'full' in /mnt/sdf/proj/diogomelo/sites/all/modules/ds/ds.module on line 980.

Accordingly with this blog this is an exception related to Zend_Db_Table_Row. It arises because the object that is being saved lost (somehow) it's reference to the the table it belongs.

To restore it's reference (and solve this issue) you just have to call setTable before saving the object:

$row->setTable(new DbTable_User()); $row->save();

In my case, I'm losing the reference to the table because I'm storing the object on a session (with Zend_Session_Namespace). Since there is, at least, three places where I have to save the row stored by the session, I decided to rewrite the save method, just like this:

 1 <?php
 2 
 3 class DbTable_UserRow extends Zend_Db_Table_Row_Abstract
 4 {
 5     public function save()
 6     {
 7         $this->setTable(new DbTable_User());
 8         parent::save();
 9     }
10 }

And then, at the DbTable_User.php I just have to set the class DbTable_UserRow as being the row class for the table user:

 1 <?php
 2 
 3 class DbTable_User extends Zend_Db_Table_Abstract
 4 {
 5     protected $_name = 'user';
 6     protected $_rowClass = 'DbTable_UserRow';
 7 

Now, whenever I save my user, it makes sure the table is set, avoiding the exception mentioned on this blog post.