像drupal_write_record一样容易阅读

时间:2010-09-08 22:51:40

标签: php database drupal drupal-6

drupal是否有像drupal_write_record这样的简单阅读版本。我想从名为{allcategories}的表中读取记录,并查找具有category字段值computers的记录。它是使用模式定义的自定义表。

3 个答案:

答案 0 :(得分:3)

$result = db_query('SELECT a.* FROM {allcategories} a WHERE a.category="%s"', 'computers');
while ($row = db_fetch_object($result)) {
  print $row->[YOURCOLUMNNAME].'<br/>';
  // other actions...
}

答案 1 :(得分:3)

你正在寻找的东西在Drupal 6中并不存在。drupal_write_record just barely made it into Drupal 6。在Drupal 7中,数据库API本身就足够直截了当,我不希望像“drupal_read_record”这样的另一个抽象层:

$record = db_select('allcategories') // table
    ->condition('category', 'computers') // field & value
    ->execute() // do it
    ->fetch(); // get the result

答案 2 :(得分:0)

据我所知,drupal没有ORM支持。已配置的ORM模块确实存在于开发状态中 http://drupal.org/project/orm/