Hi,
I have a SQL database like that:
CREATE TABLE `productos` ( `idproducto` int(10) unsigned NOT NULL auto_increment, `proveedor` int(10) unsigned default NULL, `categoria` varchar(10) NOT NULL, `precio` float default NULL, `pvp` float default NULL, `existencias` int(10) unsigned default NULL, `imagen` text NOT NULL, PRIMARY KEY (`idproducto`), KEY `FK_productos_1` (`proveedor`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=82 ;
CREATE TABLE `proveedores` ( `idproveedor` int(10) unsigned NOT NULL auto_increment, `nombre` varchar(50) NOT NULL default '', `telefono` varchar(9) default NULL, `fax` varchar(9) default NULL, PRIMARY KEY (`idproveedor`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=85 ;
CREATE TABLE `mueble` ( `idmueble` int(11) NOT NULL auto_increment, `producto` int(10) unsigned NOT NULL default '0', `ref` varchar(5) default NULL, `descripcion` varchar(250) NOT NULL default '', `color` int(10) unsigned default NULL, `material` int(10) unsigned default NULL, `medidas` varchar(20) default NULL, PRIMARY KEY (`idmueble`), KEY `FK_mueble_3` (`material`), KEY `FK_mueble_1` (`color`), KEY `FK_mueble_2` (`producto`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=81 ;
CREATE TABLE `colores` ( `idcolor` int(10) unsigned NOT NULL auto_increment, `tipocolor` varchar(25) NOT NULL default '', PRIMARY KEY (`idcolor`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=42 ;
CREATE TABLE `materiales` ( `idmaterial` int(10) unsigned NOT NULL auto_increment, `tipomaterial` varchar(45) NOT NULL default '', PRIMARY KEY (`idmaterial`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=55 ;
I need to know how to show a simple mask to management of the table called 'mueble' using this relations:
FOREIGN KEY KEY · proveedores.idproveedor -> productos.proveedor · mueble.idmueble -> productos.idproducto · mueble.color -> colores.idcolor · mueble.material -> material.idmaterial
I´m doing it like that :
$this->build("p4a_db_source", "source") ->setTable("productos") ->addJoin("mueble", "mueble.producto = productos.idproducto") ->addJoin("proveedores", "proveedores.idproveedor = productos.proveedor") ->addJoin("colores", "colores.idcolor = mueble.color") ->addJoin("materiales", "materiales.idmaterial = mueble.material") ->setWhere("productos.categoria = 'mueble'") ->setPk("idproducto") ->addOrder("idproducto") ->setPageLimit(10) ->load();
$this->setSource($this->source); $this->firstRow();
But this code sends an error: " NOTICE: Undefined offset: 1 " , and I can´t add or delete the elements of table called 'mueble'.
Can u give me an easy sample using multiple relations?¿ ¿I need to modify the saveRow() method?
Log in to post a comment.
Hi,
I have a SQL database like that:
CREATE TABLE `productos` (
`idproducto` int(10) unsigned NOT NULL auto_increment,
`proveedor` int(10) unsigned default NULL,
`categoria` varchar(10) NOT NULL,
`precio` float default NULL,
`pvp` float default NULL,
`existencias` int(10) unsigned default NULL,
`imagen` text NOT NULL,
PRIMARY KEY (`idproducto`),
KEY `FK_productos_1` (`proveedor`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=82 ;
CREATE TABLE `proveedores` (
`idproveedor` int(10) unsigned NOT NULL auto_increment,
`nombre` varchar(50) NOT NULL default '',
`telefono` varchar(9) default NULL,
`fax` varchar(9) default NULL,
PRIMARY KEY (`idproveedor`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=85 ;
CREATE TABLE `mueble` (
`idmueble` int(11) NOT NULL auto_increment,
`producto` int(10) unsigned NOT NULL default '0',
`ref` varchar(5) default NULL,
`descripcion` varchar(250) NOT NULL default '',
`color` int(10) unsigned default NULL,
`material` int(10) unsigned default NULL,
`medidas` varchar(20) default NULL,
PRIMARY KEY (`idmueble`),
KEY `FK_mueble_3` (`material`),
KEY `FK_mueble_1` (`color`),
KEY `FK_mueble_2` (`producto`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=81 ;
CREATE TABLE `colores` (
`idcolor` int(10) unsigned NOT NULL auto_increment,
`tipocolor` varchar(25) NOT NULL default '',
PRIMARY KEY (`idcolor`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=42 ;
CREATE TABLE `materiales` (
`idmaterial` int(10) unsigned NOT NULL auto_increment,
`tipomaterial` varchar(45) NOT NULL default '',
PRIMARY KEY (`idmaterial`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=55 ;
I need to know how to show a simple mask to management of the table called 'mueble' using this relations:
FOREIGN KEY KEY
· proveedores.idproveedor -> productos.proveedor
· mueble.idmueble -> productos.idproducto
· mueble.color -> colores.idcolor
· mueble.material -> material.idmaterial
I´m doing it like that :
$this->build("p4a_db_source", "source")
->setTable("productos")
->addJoin("mueble", "mueble.producto = productos.idproducto")
->addJoin("proveedores", "proveedores.idproveedor = productos.proveedor")
->addJoin("colores", "colores.idcolor = mueble.color")
->addJoin("materiales", "materiales.idmaterial = mueble.material")
->setWhere("productos.categoria = 'mueble'")
->setPk("idproducto")
->addOrder("idproducto")
->setPageLimit(10)
->load();
$this->setSource($this->source);
$this->firstRow();
But this code sends an error: " NOTICE: Undefined offset: 1 " , and I can´t add or delete the elements of table called 'mueble'.
Can u give me an easy sample using multiple relations?¿
¿I need to modify the saveRow() method?