Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello, I'm using cake v1.2.1.8004, got pretty complicated model relations defined. Esp have this relation: Member has many and belongs to many TrainingEvent, the joining table has entries with score (field name points) earned by member. Now I want to add another condition to already complicated search query that will ask if sum of member's points is within specific range (having sum(points) between x and y). Please throw me some tips how to "ask that question" in cake style (association arrays of conditions) for use with paginate. Below is the table structure:
- CREATE TABLE IF NOT EXISTS `oiu_members` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `user_id` int(11) DEFAULT NULL,
- `house_id` int(11) DEFAULT NULL,
- `numer_ewid` varchar(20) COLLATE utf8_polish_ci DEFAULT NULL,
- `ne_text` varchar(5) COLLATE utf8_polish_ci DEFAULT NULL,
- `ne_num` int(10) DEFAULT NULL,
- `data_urodzenia` date DEFAULT NULL,
- `principle_id` tinyint(1) DEFAULT NULL,
- `data_przyjecia` date DEFAULT NULL,
- `czy_postepowanie` tinyint(1) DEFAULT NULL,
- `data_postepowania` date DEFAULT NULL,
- `czy_egzamin` tinyint(1) DEFAULT NULL,
- `data_egzaminu` date DEFAULT NULL,
- `nazwisko_rodowe` varchar(50) COLLATE utf8_polish_ci DEFAULT NULL,
- `imiona_rodzicow` varchar(50) COLLATE utf8_polish_ci DEFAULT NULL,
- `miejsce_urodzenia` varchar(100) COLLATE utf8_polish_ci DEFAULT NULL,
- `obywatelstwo` varchar(50) COLLATE utf8_polish_ci DEFAULT NULL,
- `pesel` varchar(11) COLLATE utf8_polish_ci DEFAULT NULL,
- `nip` varchar(20) COLLATE utf8_polish_ci DEFAULT NULL,
- `aktualny_status` varchar(50) COLLATE utf8_polish_ci DEFAULT NULL,
- `aktualny_status_id` int(11) unsigned DEFAULT NULL,
- `aktualny_status_od` date DEFAULT NULL,
- `default_title` varchar(32) COLLATE utf8_polish_ci DEFAULT NULL,
- PRIMARY KEY (`id`),
- KEY `house_id` (`house_id`),
- KEY `user_id` (`user_id`),
- KEY `aktualny_status_id` (`aktualny_status_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci ROW_FORMAT=DYNAMIC AUTO_INCREMENT=2432 ;
- CREATE TABLE IF NOT EXISTS `oiu_members_training_events` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `oiu_member_id` int(11) NOT NULL,
- `training_event_id` int(11) NOT NULL,
- `points` int(6) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `uniq` (`oiu_member_id`,`training_event_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
- CREATE TABLE IF NOT EXISTS `training_events` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `title` varchar(255) CHARACTER SET utf8 NOT NULL,
- `descr` text CHARACTER SET utf8 NOT NULL,
- `date` datetime NOT NULL,
- `location` text CHARACTER SET utf8 NOT NULL,
- `points` int(11) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement