i'm developing an addon. While developing i'm encountering a strange problem that I don't know how to solve. It's like EE is executing the wrong queries or something.
For example, when I call this function:
$channel_info = ee()->api_channel_structure->get_channel_info(2);
The result is completely off:
echo '<pre>';
echo 'CHANNEL INFO:';
print_r($channel_info->result());
echo '</pre>';
Giving me this information:
CHANNEL INFO:Array
(
[0] => stdClass Object
(
[child_id] => 11
[order] => 3
)
[1] => stdClass Object
(
[child_id] => 4
[order] => 2
)
[2] => stdClass Object
(
[child_id] => 2
[order] => 1
)
[3] => stdClass Object
(
[child_id] => 10
[order] => 4
)
)
This is a result from a former executed query like this:
$result = ee()->db->query($sql);
$this->_result_array = $result->result_array();
Do I need to clear the db class or something? I'm not sure what's causing this. Hopefully someone can give me a push in the right direction here? :)
EDIT: Ok, I have solved the problem by adding this line:
ee()->db->_reset_select();
Before calling:
$channel_info = ee()->api_channel_structure->get_channel_info(2);
Still, I'm not sure why I have to call this manually...