继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

db_fetch_object() 和 db_fetch_array()

经常会使用到,在mysql里 mysql_fetch_object() 与mysql_fetch_array() 类似,一个返回对象,一个返回数组类型。取值的方式有点差异。 在drupal里 4.6 – 6 http://api.drupal.org/api/function/db_fetch_object/6 db_fetch_object($result) $result 从db_query()查询结果。 返回一个对象 db_fetch_array($result) 返回一个相关数组。 user_id; echo $row->fullname; } while($row = mysql_fetch_array($result)) { echo $row["user_id"]; echo $row["fullname"]; } /** *drupal */ while($row = db_fetch_array($result )){ echo $row['someColumn']; // do stuff } while($row = db_fetch_object($result)){ $node = node_load($row->nid);// node_load 返回节点对象 $node-> tilte...... // do stuff } ?>

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.