AD:
nodeテーブルからtypeをWhereに入れてSELECT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//nidだけを知りたいだけ $results = db_select('node', 'n') ->fields('n', array('nid')) ->condition('type', 'article') ->execute() ->fetchCol(); //複数のfieldsがほしいなら $results = db_select('node', 'n') ->fields('n', array('nid', 'title')) ->condition('type', 'article') ->execute(); foreach($results as $row){ var_dump($row); } //countなら $results = db_select('node', 'n') ->fields('n', array('nid', 'title')) ->condition('type', 'article') ->execute() ->rowCount(); //queryを確認したいなら $results = db_select('node', 'n') ->fields('n', array('nid', 'title')) ->condition('type', 'article') ->execute() ->getQueryString(); |
field_data_field_package_periodテーブルから日付をWhereに入れてSELECT
|
$date = new DateTime(); $results = db_select('field_data_field_package_period', 'fpp') ->fields('fpp', array('field_package_period_value2')) ->condition('field_package_period_value2', $date->format('Y-m-d H:i:s'), '<') ->execute() ->fetchCol(); |
field_data_field_package_periodテーブルからentity_idをINでSELECT
$results = db_select('field_data_field_package_level', 'fpl')
->fields('fpl', array('field_package_level_value'))
->condition('entity_id', array(1,2,3), 'IN')
->condition('field_package_level_value', 0, '!=')
->execute()
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0