phparrayscakephp

PHP query -- Returned array values


I am using the query function in cake PHP ($this->query(select...)), and I know it returns an array of the values. If the query will only return one value, what is the position of that value in the array?

Would $element = $arrayName(0) be correct?

I'm trying to use it as such:

$flowsheet_name = $this->query("select FLOWSHEET_NAME from FLOWSHEET_TEMPLATE where FLOWSHEET_ID = ".$value.";");
        $flowsheet_question = $flowsheet_name(0);
        array_push($this->$filedMethodMappings, $flowsheet_question => array(
                CaBase::KEY_MAPPING_LOGIC_COMPLEXITY => CaBase::LEVEL3_COMPLEXITY,
                CaBase::KEY_FIELD_LOGIC_NAME         => 'wsUnifiedKey',
                CaBase::KEY_FIELD_QUESTION_ID        => ''.$value,
                )
            );

But I can't tell if it's working. I'm getting a double arrow error here:

$flowsheet_question => array(

Solution

  • In CakePHP, easy way to see what is going on in your array is:

    debug($flowsheet_name);