Updating textfield in doctrine produces an exception

Posted by james-murphy on Stack Overflow See other posts from Stack Overflow or by james-murphy
Published on 2009-05-20T15:47:47Z Indexed on 2010/03/29 19:03 UTC
Read the original article Hit count: 552

I have a textfield that contains say for example the following text:-

"A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and gravy."

This textfield is in a form that simply updates an item record using it's ID. If I edit part of the textfield and replace "and gravy." with "humous." So that the textfield now contains

"A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and humous."

I get the following exception:-

Fatal error: Uncaught exception 'Doctrine_Query_Exception' with message 'Unknown component alias humous' in C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php:780 Stack trace: C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(767): Doctrine_Query_Abstract->getQueryComponent('humous') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Set.php(58): Doctrine_Query_Abstract->getAliasDeclaration('humous') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(2092): Doctrine_Query_Set->parse('i.details = 'A ...') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query.php(1058): Doctrine_Query_Abstract->_processDqlQueryPart('set', Array) C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(971): Doctrine_Query->getSqlQuery(Array) C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(1030): Doctrine_Query_Abstract->_execute(Array) C:\Projects\nitrous\lightweight\system\appl in C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php on line 780

I'm using Doctrine 1.0.6 hooked into CodeIgniter 1.7.0 if anyone is interested.

My doctrine query that actually performs the update looks as follows:-

public function updateItems($id, $arrayItem) {
    $query = new Doctrine_Query();
    $query->update('Item i');

    foreach($arrayItem as $key => $value) {
        $query->set('i.'.$key, "'".$value."'");
    }

    $query->where('i.id = ?', $id);
    return $query->execute();
}

This seems bizarre because if i replace the entire string "A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and humous." with something completely different like just "test" it doesn't throw an exception and works just fine. This baffles me... is it a bug in Doctrine or have I missed something?

© Stack Overflow or respective owner

Related posts about doctrine

Related posts about codeigniter