Tenia por ejemplo esta función y he podido comprobar que ya está obsoleta:
$total_autos = mysql_result($contador_autos_result, 0, 0) ;
en php.net me dice que puedo remplazarla por mysqli_data_seek() junto con mysqli_field_seek() y mysqli_fetch_field()
El tema es que no se como hacerlo para que me de el mismo resultado.
Les pongo todo por si acaso me dejo algo mas que esté obsoleto en mi clase
Por una lado tengo un pagina con la clase:
Código PHP:
<?php
class kpaginate{
private $ends = 2 ;
private $show = 10 ;
private $num_pgs = 0 ;
private $total_items = 0 ;
private $items_pg = 0 ;
private $pg = 0 ;
private $prefix = 'kpg' ;
private $start = 0 ;
private $stop = 0 ;
private $getvars = array() ;
private $without_numbers = false ;
private $customvar = '' ;
public static $correlative = 0 ;
function __construct(){
self::$correlative++ ;
$this->getvars = $_GET ;
}
public function withoutNumbers($bool){
$this->without_numbers = $bool ;
}
public function getLimit(){
return array(($this->pg * $this->items_pg), $this->items_pg) ;
}
public function setTotalItems($total_items){
$this->total_items = intval($total_items) ;
if($this->items_pg > 0){
$this->setNumPages() ;
if($this->customvar != ''){
$this->setCustomPage() ;
}
elseif(isset($this->getvars[$this->prefix][self::$correlative])){
$this->setPage($this->getvars[$this->prefix][self::$correlative]) ;
}
}
}
public function setItemsPerPage($items_pg){
$this->items_pg = intval($items_pg) ;
if($this->total_items > 0){
$this->setNumPages() ;
if($this->customvar != ''){
$this->setCustomPage() ;
}
elseif(isset($this->getvars[$this->prefix][self::$correlative])){
$this->setPage($this->getvars[$this->prefix][self::$correlative]) ;
}
}
}
private function setNumPages(){
$this->num_pgs = ceil($this->total_items / $this->items_pg) ;
}
private function setCustomPage(){
$pg = 0 ;
$getstr = '' ;
if(isset($this->getvars[$this->customvar])){
parse_str($this->customvar, $ctmout) ;
while(is_array($ctmout)){
$getstr .= '[\'' . current(array_keys($ctmout)) . '\']' ;
$ctmout = current(array_values($ctmout)) ;
}
eval('$pg = intval($this->getvars' . $getstr . ') ; ') ;
}
if($pg > 0 && $pg < $this->num_pgs)
$this->pg = $pg ;
else
$this->pg = 0 ;
}
private function setPage($pg){
$pg = intval($pg) ;
if($pg > 0 && $pg < $this->num_pgs)
$this->pg = $pg ;
else
$this->pg = 0 ;
}
private function createPageLink($pg){
$pg = intval($pg) - 1 ;
if($this->pg == $pg)
return ' class="selected" ' ;
if($this->customvar != ''){
$customurl = urldecode(http_build_query($this->getvars) . '&' . $this->customvar . '=' . $pg) ;
parse_str($customurl, $urlout) ;
$lnk = 'href="?' . urldecode(http_build_query($urlout)) . '"' ;
}
else{
$this->getvars[$this->prefix][self::$correlative] = $pg ;
$lnk = 'href="?' . urldecode(http_build_query($this->getvars)) . '"' ;
}
return $lnk ;
}
public function setCustomVar($varname = ''){
if(trim($varname) != '')
$this->customvar = trim(strval($varname)) ;
}
private function calculateBuffers(){
$this->left = $this->right = ceil($this->show / 2) ;
$this->start = ($this->pg + 1) - $this->left ;
$this->stop = ($this->pg + 1) + $this->right ;
if($this->start < 1){
$this->start = 1 ;
$this->stop = $this->show + 1 ;
if($this->stop > $this->num_pgs)
$this->stop = $this->num_pgs ;
}
if($this->stop > $this->num_pgs){
$this->stop = $this->num_pgs ;
$this->start = ($this->stop - $this->show) ;
if($this->start < 1)
$this->start = 1 ;
}
$this->start += $this->ends ;
$this->stop -= $this->ends ;
}
public function paginate(){
if($this->total_items > $this->items_pg){
echo '<table id="kpaginate" align="center" cellpadding="0" cellspacing="0"><tr>' ;
echo '<td><a ' . ($this->pg > 0 ? $this->createPageLink($this->pg) . ' class="back" ' : ' class="backdis" ') . '></a></td>' ;
if($this->without_numbers == false){
if($this->num_pgs <= $this->show){
for($i = 1 ; $i <= $this->num_pgs ; $i++)
echo '<td><a ' . $this->createPageLink($i) . ' class="normal">' . ($i) . '</a></td>' ;
}
else{
$this->calculateBuffers() ;
for($i = 1 ; $i <= $this->ends ; $i++)
echo '<td><a ' . $this->createPageLink($i) . ' class="normal">' . ($i) . '</a></td>' ;
if($i != $this->start)
echo '<td>...</td>' ;
for($i = $this->start ; $i <= $this->stop ; $i++)
echo '<td><a ' . $this->createPageLink($i) . ' class="normal">' . ($i) . '</a></td>' ;
if($i != ($this->num_pgs - ($this->ends - 1)))
echo '<td>...</td>' ;
for($i = ($this->num_pgs - ($this->ends - 1)) ; $i <= $this->num_pgs ; $i++)
echo '<td><a ' . $this->createPageLink($i) . ' class="normal">' . ($i) . '</a></td>' ;
}
}
echo '<td><a ' . ($this->pg < $this->num_pgs - 1 ? $this->createPageLink($this->pg + 2) . ' class="next" ' : ' class="nextdis" ') . '></a></td>' ;
echo '</tr></table>' ;
}
}
}
?>
Y recojo los resultados con esto que esta la función por ejemplo que ahora esta obsoleta:
Código PHP:
$conectando=cbd();
$contador_autos_sql = "select count(*) from prensa order by id desc " ; // le metemos la consulta deseada
$contador_autos_result = mysqli_query($conectando,$contador_autos_sql) ;
$total_autos = mysql_result($contador_autos_result, 0, 0) ;
@$cp=mysqli_query($conectando,"select * from prensa");
$conprensa=mysqli_num_rows($cp);
if($conprensa==0){ echo "<font color='black' size='3'><b>SÍN NOTICIAS POR EL MOMENTO</b></font>";}else{echo "<font color='black' size='2'><br></font>";}
$kp3 = new kpaginate ;
$kp3->setTotalItems($total_autos) ;
$kp3->setItemsPerPage(1) ;// total de noticias por pagina
$limit = $kp3->getLimit();
$autos_sql = 'select * from prensa order by id desc limit ' . $limit[0] . ', ' . $limit[1] ; // le metemos la consulta deseada con limite. Lo dejamos como esta pero xcon la cunsulta
$autos_result = mysqli_query($conectando,$autos_sql) ;
while($auto = mysqli_fetch_object($autos_result)){
$r=$auto->titulo;
$fecha=$auto->fecha;
$autor=$auto->autor;
$fuente=$auto->fuente;
$cuerpo=$auto->contenido;
$idnoticia=$auto->id;
$transf = strtotime($fecha);
$mostrarfecha = date("d/m/Y h:i:s ", $transf);
$kp3->paginate() ;