mssql_data_seek will return false AND trigger a warning ('Bad row offset') if you specify a row outside the result set.
You'll need to check beforehand if the row you are trying to seek to exists. Or you can supress the error and look for the false result, depending on your needs.
To check beforehand (where $result is the result fo your query and $seek is the row number you want to seek to):
<?php
$rowcount = mssql_num_rows($result);
if ($seek >= $rowcount)
{
print ("Trying to seek outside result set!");
}
else
{
if (!mssql_data_seek($result, $seek))
{
print ("Seek failed");
}
else
{
print ("Seek complete");
}
}
?>
To have a 'simpler' way of handling errors by supressing the warning:
<?php
if (!@mssql_data_seek($result, $seek))
{
print ("Seek failed");
}
else
{
print ("Seek complete");
}
?>
mssql_data_seek
(PHP 4, PHP 5, PECL odbtp:1.1.1-1.1.4)
mssql_data_seek — mueve el puntero interno de las filas
Descripción
int mssql_data_seek
( int $result_identifier
, int $row_number
)
Devuelve: TRUE si se ejecuta con éxito, FALSE si falla.
mssql_data_seek() mueve el puntero interno de la consulta MS SQL asociada al result_identifier especificado, para que apunte al número de fila especificada. La siguiente llamada a mssql_fetch_row() devolverá esa fila.
Ver también: mssql_data_seek().
mssql_data_seek
phpcomments at hltools dot com
20-Jul-2005 01:33
20-Jul-2005 01:33
