Simple $this->query(); On 3 jun, 15:21, yoel duran <yoeldura...@gmail.com> wrote: > saludos amigos > > mi pregunta es como debo hacer para traer los datos de dos tablas o mas > > de ellas quiero traer los datos de una persona segun el tipo desde la > vista comun donde si selecciono el tipo estudiante debe traerme todos los > datos relacionados a ese estudiante como por ejemplo sus datos personales, > su representante sus padres, su grado , seccion etc y si fuese un > representante debe de traerme los datos de ese representante asi como el > estudiantes representado > > soy nuevo en esto y me cuesta hacer las relaciones solo he logrado traer > los datos de la persona elejida pero no el resto > > este es mi script de filtrado > > function detalle($id=null){ > > $this->Comun->id = $id; > $this->set('comuns', $this->Comun->read()); > $this->Comun->Estudiante->id=$id; > $this->set('estudiantes',$this->Comun->Estudiante->read()); > > } > > las cuestion es que tengo tengo las siguiente tablas > > aqui les dejo el script > > -- phpMyAdmin SQL Dump > -- version 3.4.5deb1 > --http://www.phpmyadmin.net > -- > -- Servidor: localhost > -- Tiempo de generación: 02-06-2012 a las 23:00:05 > -- Versión del servidor: 5.1.62 > -- Versión de PHP: 5.3.6-13ubuntu3.6 > > SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; > SET time_zone = "+00:00"; > > /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; > /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; > /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; > /*!40101 SET NAMES utf8 */; > > -- > -- Base de datos: `lacandelaria` > -- > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `anioescolares` > -- > > CREATE TABLE IF NOT EXISTS `anioescolares` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `nombre` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `comuns` > -- > > CREATE TABLE IF NOT EXISTS `comuns` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `apellidos` varchar(50) NOT NULL, > `nombres` varchar(50) NOT NULL, > `cedula` varchar(50) NOT NULL, > `sexo` varchar(20) NOT NULL, > `tipo_id` int(11) NOT NULL, > `created` datetime NOT NULL, > `modified` datetime NOT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `cedula` (`cedula`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; > > -- > -- Volcado de datos para la tabla `comuns` > -- > > INSERT INTO `comuns` (`id`, `apellidos`, `nombres`, `cedula`, `sexo`, > `tipo_id`, `created`, `modified`) VALUES > (1, 'duran', 'yoel', '17175809', 'masculino', 4, '2012-06-02 02:01:05', > '2012-06-02 02:01:05'), > (2, 'rodrigues', 'jose', '123456', 'masculino', 1, '2012-06-02 03:06:30', > '2012-06-02 03:06:30'); > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `datosacademicos` > -- > > CREATE TABLE IF NOT EXISTS `datosacademicos` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `estudiante_id` int(11) NOT NULL, > `anioescolare_id` int(11) NOT NULL, > `grado_id` int(11) NOT NULL, > `seccion_id` int(11) NOT NULL, > `fechaingreso` date NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `estudiantes` > -- > > CREATE TABLE IF NOT EXISTS `estudiantes` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `cod` varchar(30) NOT NULL, > `lugar_nac` varchar(100) NOT NULL, > `fecha_nac` date NOT NULL, > `nacionalidad` varchar(20) NOT NULL, > `tipo_sangre` varchar(10) NOT NULL, > `condicion` varchar(10) NOT NULL, > `sector` varchar(20) NOT NULL, > `email` varchar(50) DEFAULT NULL, > `telefono` int(20) DEFAULT NULL, > `foto` text, > `comun_id` int(11) NOT NULL, > `created` datetime NOT NULL, > `modified` datetime NOT NULL, > `tipo_id` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ; > > -- > -- Volcado de datos para la tabla `estudiantes` > -- > > INSERT INTO `estudiantes` (`id`, `cod`, `lugar_nac`, `fecha_nac`, > `nacionalidad`, `tipo_sangre`, `condicion`, `sector`, `email`, `telefono`, > `foto`, `comun_id`, `created`, `modified`, `tipo_id`) VALUES > (1, '', 'ghdghdh', '2001-06-07', 'fghfg', 'fgh', 'repitiente', 'hgh', '', > 0, 'alumnos.png', 1, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 4), > (2, '', 'la victoria', '2001-10-10', 'venezolano', 'orh+', 'regular', 'la > candelaria', '', 0, 'login.png', 0, '0000-00-00 00:00:00', '0000-00-00 > 00:00:00', 4), > (3, '', '', '2007-01-03', '', '', 'repitiente', '', '', 0, '', 0, > '0000-00-00 00:00:00', '0000-00-00 00:00:00', 4), > (4, '', 'La victoria ', '1988-03-30', 'vanezolano', 'orh+', 'repitiente', > 'la candelaria', '', 4, 'online.jpg', 2, '2007-01-03 07:26:05', '2007-01-03 > 07:26:05', 4), > (5, '', '', '2007-01-04', '', '', 'regular', '', '', 0, '', 0, '2007-01-04 > 12:16:33', '2007-01-04 12:16:33', 4), > (6, '', 'hdhd', '2007-01-04', 'fgdfg', 'fgd', 'regular', 'gfdg', '', 0, > 'alumnos.png', 0, '2007-01-04 23:31:19', '2007-01-04 23:31:19', 4), > (7, '', 'fdfsdfffffffffff', '2012-05-31', 'fffsdfsdf', 'sfsdf', 'regular', > 'sdfs', 'yoeldura...@gmail.com', 0, '', 0, '2012-05-31 08:39:38', > '2012-05-31 08:39:38', 0), > (8, '', 'hjh', '1994-06-02', 'hjj', 'orh+', 'regular', 'la', '', NULL, > 'P280412_10.40.jpg', 0, '2012-06-02 02:24:55', '2012-06-02 02:24:55', 0), > (9, '', 'dfgdfg', '2012-06-02', 'gdfg', 'dfgd', 'regular', 'fg', '', NULL, > 'P280412_10.41_[01].jpg', 0, '2012-06-02 02:28:25', '2012-06-02 02:28:25', > 0), > (10, '', 'gsfg', '1997-05-02', 'sgg', 'gsfgs', 'regular', 'sg', '', NULL, > 'P280412_12.29.jpg', 0, '2012-06-02 02:37:13', '2012-06-02 02:37:13', 0), > (11, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 03:39:51', '2012-06-02 03:39:51', 0), > (12, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 04:32:32', '2012-06-02 04:32:32', 0), > (13, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 04:47:26', '2012-06-02 04:47:26', 0), > (14, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 04:47:54', '2012-06-02 04:47:54', 0), > (15, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 04:51:32', '2012-06-02 04:51:32', 0), > (16, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 05:03:28', '2012-06-02 05:03:28', 0), > (17, '', '', '0000-00-00', '', '', '', '', NULL, NULL, NULL, 0, '2012-06-02 > 05:03:50', '2012-06-02 05:03:50', 0); > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `estudiantes_materias` > -- > > CREATE TABLE IF NOT EXISTS `estudiantes_materias` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `estudiante_id` int(11) NOT NULL, > `datosacademico_id` int(11) NOT NULL, > `materia_id` int(11) NOT NULL, > `estatus` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `estudiantes_representantes` > -- > > CREATE TABLE IF NOT EXISTS `estudiantes_representantes` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `estudiante_id` int(11) NOT NULL, > `representante_id` int(11) NOT NULL, > `parentesco_id` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `grados` > -- > > CREATE TABLE IF NOT EXISTS `grados` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `nombre` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `grados_secciones` > -- > > CREATE TABLE IF NOT EXISTS `grados_secciones` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `grado_id` int(11) NOT NULL, > `seccion_id` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `materias` > -- > > CREATE TABLE IF NOT EXISTS `materias` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `nombre` varchar(30) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `padres` > -- > > CREATE TABLE IF NOT EXISTS `padres` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `direccion` varchar(100) NOT NULL, > `telf` varchar(20) NOT NULL, > `vive_alu` varchar(2) NOT NULL, > `habilidades` text NOT NULL, > `comun_id` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `parentescos` > -- > > CREATE TABLE IF NOT EXISTS `parentescos` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `nombre` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `representantes` > -- > > CREATE TABLE IF NOT EXISTS `representantes` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `profesion` varchar(20) NOT NULL, > `direccion_habitacion` varchar(100) NOT NULL, > `trabaja` varchar(3) NOT NULL, > `direccion_trabajo` text NOT NULL, > `fecha_nac` varchar(30) NOT NULL, > `telf_habitacion` varchar(30) NOT NULL, > `foto` text, > `comun_id` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `secciones` > -- > > CREATE TABLE IF NOT EXISTS `secciones` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `nombre` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `tipos` > -- > > CREATE TABLE IF NOT EXISTS `tipos` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `name` varchar(20) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; > > -- > -- Volcado de datos para la tabla `tipos` > -- > > INSERT INTO `tipos` (`id`, `name`) VALUES > (1, 'Padre'), > (2, 'Madre'), > (3, 'Representante'), > (4, 'Estudiante'), > (5, 'Docente'); > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `users` > -- > > CREATE TABLE IF NOT EXISTS `users` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `username` varchar(30) NOT NULL, > `password` text NOT NULL, > `created` datetime NOT NULL, > `nombres` varchar(50) NOT NULL, > `apellidos` varchar(50) NOT NULL, > `role` varchar(50) NOT NULL, > `sexo` varchar(30) NOT NULL, > `modified` datetime NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; > > -- > -- Volcado de datos para la tabla `users` > -- > > INSERT INTO `users` (`id`, `username`, `password`, `created`, `nombres`, > `apellidos`, `role`, `sexo`, `modified`) VALUES > (1, 'admin', '1234', '2007-01-02 04:13:39', 'yoel', 'duran', '', > 'masculino', '2007-01-02 04:13:39'), > (2, 'admin', 'fc093a5e1b11884b2b4de7c76ebb575b0324d07f', '2007-01-02 > 04:23:16', 'gdfg', 'dgdfg', 'administrador', 'masculino', '2007-01-02 > 04:23:16'), > (3, 'yoel', 'fc093a5e1b11884b2b4de7c76ebb575b0324d07f', '2012-05-30 > 20:30:39', 'yoel', 'duran', 'docente', 'masculino', '2012-05-30 20:30:39'); > > -- -------------------------------------------------------- > > -- > -- Estructura de tabla para la tabla `vacantes` > -- > > CREATE TABLE IF NOT EXISTS `vacantes` ( > `id` int(11) NOT NULL AUTO_INCREMENT, > `grado_id` int(11) NOT NULL, > `seccion_id` int(11) NOT NULL, > `vacantes` int(3) NOT NULL, > `vacantes_rest` int(11) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; > /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; > /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- Has recibido este mensaje porque estás suscrito al grupo "CakePHP-es" de Grupos de Google. Para publicar una entrada en este grupo, envía un correo electrónico a cakephp-es@googlegroups.com. Para anular tu suscripción a este grupo, envía un correo electrónico a cakephp-es+unsubscr...@googlegroups.com Para tener acceso a más opciones, visita el grupo en http://groups.google.com/group/cakephp-es?hl=es.