Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
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 at 13:44
add comment (requires an account with 50 reputation)

1 Answer

up vote 0 down vote accepted
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.

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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