how use mysql_data_seek with PDO?

后端 未结 4 1701
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 22:57

I want use mysql_data_seek with PDO from google search I found that it should looks like this:

$row0 = $result->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 23:50

    You could do it like this:

    $c = 1;
    $saved=null; 
    while($row = $q->fetch()){
        if($c==4){
            $saved = clone $row;
        };
        $c++;
        somethingelse;
    }
    

    $saved will then contain the 4th element as an object with almost no extra overhead calculations.

提交回复
热议问题