zoukankan      html  css  js  c++  java
  • drupal 数据库查询的两种方式 奇

        $select = db_select('node', 'n')
                   ->condition('n.type','product')
                   ->fields('n', array('nid', 'title', 'created'))
                   ->execute();
        foreach($select as $row){
            dpm($row);
        }
    

     或者

        $select = db_select('node', 'n')
            ->condition('n.type','product_sell_quote')
            ->fields('n', array('nid', 'title', 'created'))
            ->execute()
            ->fetchAllAssoc('nid');
        foreach($select as $row){
            dpm($row);
        }
    

     都是可以的 ...

    -- 还有一个备注:
    db_select确定表格
    fields确定字段
    condition确定条件
    然后触发execute

  • 相关阅读:
    ADO.NET存取数据库数据
    2017-01-03
    re模块
    random模块(随机)
    sys模块
    os模块
    datetime模块
    time模块
    logging模块
    Python函数初识
  • 原文地址:https://www.cnblogs.com/qinqiu/p/4723615.html
Copyright © 2011-2022 走看看