Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2012, 15:18
dave_river89
 
Fecha de Ingreso: mayo-2012
Mensajes: 24
Antigüedad: 11 años, 11 meses
Puntos: 0
Error query offset no puede ser negativo

Buenas tengo un error en una aplicacion que estoy migrando a php 5.3 y postgres 9.1 pero tengo este ultimo error que corregir es sobre el offset me lanza un mensaje de query diciendome que no puede ser negativo cuando intento hacer una busqueda de usuarios a traves de mi aplicacion, me dice que la falla esta en el archivo de conexion de postgres en estas lineas

public function getPage($sql,$sql2,$pag,$paso){
if (is_null($sql) || $sql =="") throw new Exception("",1203);
$inicio = ( ($pag - 1 ) * $paso ) + 0 ;
$fin = $inicio + $paso - 1;

/* arreglar esto */
$result = pg_query($this->conn, $sql2);
$row = pg_fetch_array( $result);
$num_rows_T = $row['count'];
// $num_rows_T = pg_num_rows( $result );


$sql .= ' limit '.$paso.' offset '.$inicio;

$result = pg_query($this->conn, $sql);
if ( is_null($result) ) throw new Exception($sql."<br>",1204);
$num_campos = pg_num_fields( $result );
/* comienza en 0 */
for($i = 0 ; $i < $num_campos ; $i++)
$this->dataset->append(pg_field_name($result,$i),pg_field_type($r esult,$i));
//$r = 0;
$k = 0;

if ( $num_rows = pg_num_rows( $result ) ){
$inicio = 0 ;
$fin = $num_rows;
while ($row = pg_fetch_array( $result) ){
$k++;
if ( $k < $inicio ) continue;
if ($k > $fin ) break;
$j = 0;
$this->dataset->addNew($k);
foreach($row as $key=>$value) {
if (!is_int($key)) {
$j++;
if( !$this->dataset->setValue_ind($j, $value))
throw new Exception("",1202);

Aunque encontré otro archivo donde esta el comando offset no se si tendrá que ver con este error si me puede ayudar se los agradecería aqui se los comparto.

http://dl.dropbox.com/u/33668916/pag_html2ps.php