-2

I want to select id from moodle database where name is equal to some variable.I am trying this statement but so far its not working.

$questionname=  $DB->get_record_sql('SELECT id 
                      FROM {question} WHERE name = ?', array($name));
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
Usman Qadeer
  • 157
  • 1
  • 12

1 Answers1

1
$questionid = $DB->get_field('question', 'id', array('name' => $name));

https://docs.moodle.org/dev/Data_manipulation_API#Getting_a_particular_field_value_from_one_record

Russell England
  • 9,436
  • 1
  • 27
  • 41