Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2010, 09:17
juansiruiz
 
Fecha de Ingreso: enero-2009
Mensajes: 142
Antigüedad: 15 años, 3 meses
Puntos: 0
Pregunta Optimizar una funcion (AYUDA)

hola amigos actualmente tengo una funcion en la cual estoy haciendo consultas a mysql. necesito saber si estas son las mejores practicas para esto.

funciones
Código PHP:
function SqlNoticia(){
          
$SQL="SELECT CodNotic,TitNotic,ResumnNotic,DesNotic,DATE_FORMAT(FecNotic,'%d/%m/%Y') as Fecha, DATE_FORMAT(FecNotic,'%H:%i %p') as Hora, DATE_FORMAT(FecSistem,'%H:%i %p') as HoraSistem, ifnull(total_votes,0) as Votos FROM notic LEFT JOIN ratings ON notic.CodNotic = ratings.id";
        
$SQL .= " Where notic.Tipo=0 ".cWhereFecha;
        
//and DATE_FORMAT(FecNotic,'%d/%m/%Y') = ( Select DATE_FORMAT(Max(FecNotic),'%d/%m/%Y') from notic where DATE_FORMAT(FecNotic,'%d/%m/%Y') <= DATE_FORMAT(NOW(),'%d/%m/%Y') )
          
return $SQL;
      } 
esta es la consulta

Código PHP:
<?php
                        $SQL
=SqlNoticia();
                         
$SQL .=" and PosicnColumn=2 ";
                        
$SQL .=" group by CodNotic,TitNotic,ResumnNotic,FecNotic order by PosicnColumn,FecNotic Desc Limit 2";
                        
$i=0;
                        
$SQL=SQLSeguro($SQL);
                        if (
$dbh){
                            
$Datos mysql_query($SQL);
                            if (
$Datos) {
                                include(
"datosnoticia.php");
                            }
                        }
?>
espero por sus sugerencias gracias