Welcome Guest, Not a member yet? Register   Sign In
ORACLE & Active Record :)
#1

[eluser]sikkle[/eluser]
Hi there,

Code:
function get_bla_2()
    {    
        
        $this->db->select('*');
      $this->db->from('TRAMP');
      $query = $this->db->get();    
        
        if($query->num_rows())
        {
            $ready = $query->result_array();
            $query->free_result();    
            return $ready;
        }
        
        else
        {
            return false;
        }
    }

Result ?

Code:
An Error Was Encountered
Error Number:

SELECT * FROM (`TRAMP`)

We all agree something is going on, someone have see some solution about that to let us use active record with ORACLE ?

Thanks !
#2

[eluser]axle_foley00[/eluser]
I think it might be because of the quote identifiers (in this case the backticks `) surrounding the table name (that appear in your error). Based on the documentation, quote identifiers are automatically used in Active Record and I don't think there is a way to disable them (I could be wrong though). Try manually typing your query and see if that helps.

Code:
$query = $this->db->query('SELECT * FROM TRAMP');

Let me know if that works or not.
#3

[eluser]Derek Allard[/eluser]
Sikkle, apologoies. Could you let me know if its the `backticks` or if its the (brackets) in there?
#4

[eluser]sikkle[/eluser]
don't apologies dereck Smile

yes, here a bit of hacking i do actually, but not in final version and maybe want a feedback from you.


first thing i remove totally is this part, i think i do not have to remove everythings from there.

Quote:function _protect_identifiers($item, $first_word_only = FALSE)
{
return $item;
}

This part is less drastic :

Code:
function _protect_identifiers($item, $first_word_only = FALSE)
    {
        if (is_array($item))
        {
            $escaped_array = array();

            foreach($item as $k=>$v)
            {
                $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
            }

            return $escaped_array;
        }    

        // This function may get "item1 item2" as a string, and so
        // we may need "`item1` `item2`" and not "`item1 item2`"
        if (ctype_alnum($item) === FALSE)
        {
            // This function may get "field >= 1", and need it to return "`field` >= 1"
            $lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';

            //old
            //$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
    
            // new code for 565
            $item = $item;
        }
        else
        {
            //old
            //return "`{$item}`";
            //new
            return "{$item}";
        }

        $exceptions = array('AS', '/', '-', '%', '+', '*');
        
        foreach ($exceptions as $exception)
        {
        
            if (stristr($item, " `{$exception}` ") !== FALSE)
            {
                $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
            }
        }
        return $item;
    }

Little change about this implode Smile

Code:
function _from_tables($tables)
{
    if (! is_array($tables))
    {
        $tables = array($tables);
    }
        
    //old
    //return '('.implode(', ', $tables).')';
    return ''.implode(', ', $tables).'';
}

So dereck, i think it's will be good for the community to give it some try, i will soon use the pagination stuff and keep you posted about the oracle driver day to day reaction.

Hope this help.

see ya arround.
#5

[eluser]Derek Allard[/eluser]
OK thanks. So do both the backticks AND the brackets cause oracle to choke then?
#6

[eluser]sikkle[/eluser]
yep, actually this is right. i had to remove both of them.
#7

[eluser]sikkle[/eluser]
If you have elegant way to remove them, better than me indeed Smile just keep me posted.

thanks dereck.
#8

[eluser]Derek Allard[/eluser]
sikkle, would you mind emailling me ([email protected]). I'd like to give you a new file to test on Oracle. If it works, I'll roll it into CI.
#9

[eluser]axle_foley00[/eluser]
Hmm...I didn't think the brackets would have caused a problem. Glad you two were able to work out a possible solution. Smile

Derek: Any chance you can add a way to disable quote identifiers, should the developer not want to use them?

In any case Derek and sikkle, you guys Rock! Smile
#10

[eluser]Derek Allard[/eluser]
Not globally, however I've uploaded a series of database fixes that should reduce the impact of escaping in non-mysql databases.




Theme © iAndrew 2016 - Forum software by © MyBB