Hi Codeigniter Experts.
I'm compiling a QUERY by several calls to a function.
When it is done I'll use the QUERY to retrieve some data of course.
Each call, calls another function which gets and returns some translations which is supposed to be used in the QUERY
But it seems like that the WHERE condition in translation funciton gets concatinated by the WHERE condition which I'm compiling in the main QUERY
private function add_to_asq($field_name, $values)
{
.
.
.
.
$result = array();
foreach( $values[$last_level] as $val )
{
foreach( $val as $v )
{
$result[] = $this->db->escape( $this->asq_value_translate( $last_level, $v, $field_name ) );
}
}
$this->db->where_in( sprintf( '%1$s' , $field_name ) , implode( ',' , $result ) );
}
private function asq_value_translate( $level, $value_md5 , $field_name )
{
$this->db->select( sprintf( 'level_%1$d, level_%1$d_value' , $level ) )
->distinct()
->from('search_options_tree_view')
->where( sprintf( 'md5( level_%1$d_value ) = ' , $level ), $value_md5 )
->where( 'field_name' , $field_name );
$q = $this->db->get();
$value_name = sprintf( 'level_%1$d' , $level );
$row = $q->row(0);
$q->free_result();
return $row->$value_name;
}
and the DB complains about it
Error Number: 1054
Unknown column 'type' in 'where clause'
SELECT DISTINCT `level_1`, `level_1_value` FROM (`search_options_tree_view`) WHERE
`type` IN ('\'Forhandler\'')
AND md5( level_1_value ) = '138be735c55896dbdbea9b6c5d503b6f' AND `field_name` = 'fuel'
Filename: C:\wamp\www\system\database\DB_driver.php
Line Number: 330
As you see the type
IN ('\'Forhandler\'') has not anything to with the asq_value_translation.
Do you have a suggestion?
I've thought of cloning the db-object but then I thought that I ask first and shoot later.
Thanks a lot and have a nice time.