Para mi que es el "whereClause" del select, pero se tendría que mostrar bien.
La idea fue crear un SP que sirviera para mostrar noticias publicadas, no-publicadas y todas.
EL parámetro de entrada es: "in inPublicadas bool"
Código del SP:
Código:
Script de creación de la tabla:DECLARE whereClause VARCHAR(255); IF inPublicadas = TRUE THEN SET whereClause = "WHERE not_publicada = 1"; ELSEIF inPublicadas = FALSE THEN SET whereClause = "WHERE not_publicada = 0"; ELSE SET whereClause = ""; END IF; SELECT * FROM noticias whereClause ORDER BY not_fecha ;
Código:
El SP lo llamo con "CALL SelectNoticias(0);" o "CALL SelectNoticias(1);" .... o TRUE o FALSE y siempre me da lo mismo. CREATE TABLE `noticias` ( `not_id` int(11) NOT NULL auto_increment, `not_titulo` varchar(255) NOT NULL, `not_noticia` text NOT NULL, `not_fecha` datetime NOT NULL, `not_publicada` tinyint(1) NOT NULL default '0' COMMENT '1 = publicado', PRIMARY KEY (`not_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1