I am trying to get the emails from two different tables, in order to gather them in a single array to send mass messages to all subscribers.
I do not know if I can do it this way but what I did in the controller was send the name of two tables to the model like this:
static public function mensajesMasivosController(){
if(isset($_POST["tituloMasivoEs"])){
$respuesta = MensajesModelEs::seleccionarEmailSuscriptores("suscriptorespanol");
$respuesta .= MensajesModelEs::seleccionarEmailSuscriptores("suscriptorform");
}
}
Now this I put in the model
static public function seleccionarEmailSuscriptores($tabla){
$stmt = Conexion::conectar()->prepare("SELECT email FROM $tabla");
$stmt .= Conexion::conectar()->prepare("SELECT email FROM $tabla");
$stmt->execute();
return $stmt -> fetchAll();
$stmt -> close();
}
Now I get this error:
Recoverable fatal error: Object of class PDOStatement could not be converted to string
What could I do to select info from two tables at the same time?
Thanks for your reply