0

我需要从查询结果资源中读取两次数据。我曾尝试使用以下查询,但它不起作用。

$result = db_query("SELECT * FROM test");


echo '<pre>';

print_r($result->fetchAssoc());

mysql_data_seek($result, 0);

print_r($result->fetchAssoc());

只是我尝试再次通过 $result->fetchAssoc() 函数迭代结果一次我想从第一行迭代记录所以我使用了 mysql_data_seek 但它不起作用

我如何mysql_data_seek在drupal7中使用?

4

1 回答 1

0

Drupal 7 uses PDO so the short answer is you don't use the deprecated mysql_ family of functions anywhere. If you are using those functions, you're doing something wrong.

An equivalent of your code using the Drupal API:

$result = db_query("SELECT * FROM test")->fetchAllAssoc('p_key');

print_r($result[0]);
print_r($result[0]);

See this post for a list of the other helper methods you can use.

于 2012-12-20T13:56:45.440 回答