Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-26-2008, 05:42 AM
Junior Member
 
Join Date: Apr 2008
Posts: 10
Default joining Table Zend_Db_Table_Abstract and getting values

hi,
I am trying to join two tables
my blog_post table has field 'post_category' Which contains number and that is related to my
'blog_category' table with the text, its like id-value pair

blog_post Blog_category
'1' 'general'

But I cannot join table and fetch related data.
Below is the information, your help is highly appreciated, thanks

I have two tables in a database

-> Blog_posts ('id' ,'post_category','post_title','post_content')
-> Blog_category ('term_id','name')


My model class is as below

class Blog extends Zend_Db_Table_Abstract {
protected $_name = 'blog_posts';
protected $_dependentTables = array('Blog_Category');
}

class Blog_Category extends Zend_Db_Table_Abstract {
protected $_name = 'blog_category';
protected $_referenceMap = array(
'Blog' => array(
'columns' => array('term_id'),
'refTableClass' => 'blog',
'refColumns' => array('post_category')
)
);
}


My controller is as below

$blog1 = new Blog();
$row = $blog1->fetchRow('id = 1');
$this->view->cat = $row->findDependentRowset('Blog_Category');


but I get this error message

Fatal error: Uncaught exception 'Zend_Db_Table_Exception'
with message 'No reference from table Blog_Category to table Blog'……
…………………………………… Zend_Db_Table_Abstract->getReference('Blog', NULL) #1

sorry for the indentations it flattens to left side
thanks for your help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2008, 03:15 AM
Junior Member
 
Join Date: Apr 2008
Posts: 10
Default

hi all it fixed
i typed 'blog' instead of 'Blog' in below line

'refTableClass' => 'blog', (which should be 'refTableClass' => 'Blog',

actually this guy helped me to solve it 'kwylez'
i posted the same question at this forum
Nabble - Zend DB - joining Table Zend_Db_Table_Abstract and getting values

thats the link where the answer was given

thanks all of you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:19 AM.