0

Can I get all the values of delta field from "block" table from the database in my custom module

I have tried with this code as clive has explained it here but it shows me an error:

 $query = db_select('module__block', 'b')
  ->condition('theme', $business)
  ->condition('status', 1)
  ->condition('region', -1, '<>');


    $query->addExpression("CONCAT('_', delta)", 'delta');
    $deltas = $query->execute()->fetchCol();
    print_r($deltas);

module__block : Is the name of the block table since I attached a prefix to it.

1
  • 1
    Never attach prefixes defined in config.php to table names manually. For db_select use unprefixed name. For db_query use name in {fancy parenthesis}.
    – Mołot
    Jun 6, 2013 at 13:44

1 Answer 1

0
SELECT delta, 
FROM  `module__block` 
WHERE theme LIKE  'business'
LIMIT 0 , 30 ;

shows only blocks.

SELECT delta, theme FROM module__block WHERE theme LIKE 'business' LIMIT 0 , 30;

It will shows both the block names and theme name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.