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

I have a simple table with four field email,title,url & status

status can be '0' or '1'

There can be multiple values with status '1'. I want to store the all datas from the table with status '1' in array so i can output it later.

$values = db_query('select email,title,url from {example_table} where status= :one', array(':one' => '1'))->fetchAssoc();

The above array only stores one record in $values array.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

fetchAssoc() is only supposed to return a single result.

You're probably looking for Statement::fetchAllAssoc()

Returns the result set as an associative array keyed by the given field.

share|improve this answer

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.