Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/07/2009, 14:30
Ale17
 
Fecha de Ingreso: junio-2004
Mensajes: 66
Antigüedad: 19 años, 10 meses
Puntos: 0
Respuesta: Problema al querer ordenar por id

el codigo mas completo es asi:


function getData($id) {

if (!$this->db) return(false);

// Find item's data
$result = @mysql_query("SELECT * FROM ".$this->dbtable." WHERE id='".mysql_real_escape_string($id)."' order by id DESC", $this->db);
if (!$result) return(false);

// Item not found, return 0,0
if (mysql_num_rows($result) < 1) return($this->prepareOutput(0,0));

// Item found, return item's data
$item = mysql_fetch_assoc($result);
return($this->prepareOutput($item['votes'], $item['votesSum']));

}

function saveRate($id, $score) {

if (!$this->db) return(false);

// Insert or update item's data
$result = @mysql_query("INSERT INTO ".$this->dbtable." SET id='".mysql_real_escape_string($id)."', votes=1, votesSum=".$score." ON DUPLICATE KEY UPDATE votes=votes+1, votesSum=votesSum+".$score, $this->db);
if (!$result) return(false);

return('ok');

}


lo que veo es que para insertar los datos hay un SET, no se si es por eso que luego no sabe como ordenarlos, sera por eso? para probarlo desde SQL no se que valor ponerle al id porque este tiene un mysql_real_escape_string