How to find all categories where language_id is equal querystring? For
example i want all data from table categories where language_id is
equal querystring (categories/view/language_id). Please Help me . I'm
new in cake.
SQL:
CREATE TABLE `categories` (
`id` int(11) NOT NULL auto_increment,
`language_id` int(11) NOT NULL,
`kategoria` tinytext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=49 ;
INSERT INTO `categories` (`id`, `language_id`, `kategoria`) VALUES
(1, 25, 'Menu'),
(2, 25, 'Jezyki'),
---------
CREATE TABLE `languages` (
`id` int(11) NOT NULL auto_increment,
`language` varchar(30) NOT NULL,
`picture` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;
INSERT INTO `categories` (`id`, `language_id`, `picture`) VALUES
(1, 'croatian', '1.jpg'),
(2, 'english', '2.jpg'),
-----------------
Model Category:
class Category extends AppModel {
var $belongsTo = array(
'Language' => array(
'className' => 'Language',
'foreignKey' => 'language_id'
)
);
}
Model Language:
class Language extends AppModel {
var $hasMany = array(
'Category' => array(
'className' => 'Category',
'foreignKey' => 'language_id'
)
);
}
---------------------
Controller Categories :
class CategoriesController extends AppController {
var $scaffold;
var $name = 'Categories';
function menu_list()
{
$this->set('categories', $this->Category->findAll());
}
function view($id = null)
{
$this->Category->id = $id;
$this->set('category', $this->Category->read());
}
}
----------------------
view.thtml
<?php echo $category['Category']['id']; ?>
<?php echo $category['Category']['language_id']; ?>
<?php echo $category['Category']['kategoria']; ?>
My example works only for this view: categories/view/1 and retrieves
only data where id from table categories is equal quesry string. I
want only this data where language_id form table categories is equal
quesrystring.
Regards
Stachu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---