amigo muchas gracias por responder, la verdad logre mostrar lo que queria de esta manera, no se si seria un consulta muy barbara, me refiere a q me podria dar error en algun futuro
Código PHP:
Ver originalpublic function LibrosPExternos()
{
$tipo = 'EXTERNO';
$sql = "select
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='01' AND tipoprestamo = '".$tipo."') as enero,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='02' AND tipoprestamo = '".$tipo."') as febrero,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='03' AND tipoprestamo = '".$tipo."') as marzo,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='04' AND tipoprestamo = '".$tipo."') as abril,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='05' AND tipoprestamo = '".$tipo."') as mayo,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='06' AND tipoprestamo = '".$tipo."') as junio,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='07' AND tipoprestamo = '".$tipo."') as julio,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='08' AND tipoprestamo = '".$tipo."') as agosto,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='09' AND tipoprestamo = '".$tipo."') as septiembre,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='10' AND tipoprestamo = '".$tipo."') as octubre,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='11' AND tipoprestamo = '".$tipo."') as noviembre,
(select count(*) from prestamos where YEAR(fechaprestamo) = '".$year."' AND MONTH(fechaprestamo) ='12' AND tipoprestamo = '".$tipo."') as diciembre";
foreach ($this->dbh->query($sql) as $row)
{
$this->p[] = $row;
}
return $this->p;
$this->dbh=null;
}