I have the same problem so i wrote a correctif not a patch but soon i
wrote a good patch to correct the update pb for postgresql.
This correctif solve the problem for simple update and update with
join conditions.
In the file dbo_source.php at the line 1245 : you replace the line:
case 'update':
     return "UPDATE ......"

by:
                    case 'update':
                                //PATCH BY BLACKSHACK (2008) FOR POSTGRES
                                $rta = trim(str_replace('AS ', '', 
$alias));//real table alias

                                $fields = preg_replace("/{$rta}/", "{$table}", 
$fields);
                                $conditions = preg_replace("/{$rta}/", 
"{$table}", $conditions);
                                $joins = preg_replace("/{$rta}/", "{$table}", 
$joins);
                                $a_joins = split('LEFT JOIN', $joins);
                                array_shift($a_joins);

                                $f_joins = array();//FROM de jointure
                                $w_joins = array();//WHERE de jointure
                                foreach($a_joins as $join) {
                                        $join = trim($join);
                                        if(!empty($join)) {
                                                $dataJoin = split(' ON ', 
$join);
                                                $f_joins[] = trim($dataJoin[0]);
                                                if(isset($dataJoin[1])) {
                                                        $w_joins[] = 
trim($dataJoin[1]);
                                                }
                                        }
                                }

                                $where = $from = '';
                                if(!empty($f_joins)) {
                                        $first = true;
                                        for($i = 0; $i < count($f_joins); $i++ 
) {
                                                if(isset($w_joins[$i])) {
                                                        if(!$first){
                                                                $from .= ', ';
                                                                $where .= ' AND 
';
                                                        } else {
                                                                $first = false;
                                                                $from = ' FROM 
';
                                                        }
                                                        //je m'assure que pour 
chaque jointures il y a une conditions
associé.
                                                        //cela ne gênerai pas 
la présence d'une table en plus, mais
ferait une jointure inutile en plus donc...
                                                        $from .= $f_joins[$i];
                                                        $where .= 
preg_replace("/(^\(|\)$)/", '', $w_joins[$i]);
                                                }
                                        }
                                }
                                if($where !== '') {
                                        if(trim($conditions) === '') {
                                                $conditions = ' WHERE '.$where;
                                        } else {
                                                $conditions .= ' AND '.$where;
                                        }
                                }

                                return "UPDATE {$table} SET {$fields} {$from} 
{$conditions}";



ATTENTION !! this patch make cakephp work only for postgresql!!! you
could make a conditon postgresql/mysql if you know how known which db
is used and switch on.
The code is 'long' because data given is already preformated for
mysql, i must extract info and clean it before.
Ine a future really multi SGBD framework, informations don't be
arranged for a SGBD before call the renderStatement method.

"Bonne chance"
On 21 jan, 14:58, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I'm having trouble making UPDATE queries in PostgreSQL. I know that
> there is a known issue about Postgres not supporting aliases in UPDATE
> queries. Anyway, my problem is that when I try to create new Aro like
> this:
>
>                 $parent = $this->Acl->Aro->findByAlias('SuperUser');
>                 $parentId = $parent['Aro']['id'];
>
>                 $this->Acl->Aro->create();
>                 $this->Acl->Aro->save(array(
>                         'foreign_key' => null,
>                         'parent_id' => $parentId,
>                         'alias' => 'User:30'));
>
> I get the following error:
>
> Warning (2): pg_query() [function.pg-query]: Query failed: ERROR:
> column "Aro" of relation "aros" does not exist
> LINE 1: UPDATE "aros" AS "Aro"  SET "Aro"."lft" = "Aro"."lft" + 2
> W...
>                                     ^ [CORE\cake\libs\model\datasources
> \dbo\dbo_postgres.php, line 123]
> $sql    =       "UPDATE "aros" AS "Aro"  SET "Aro"."lft" = "Aro"."lft" + 2
> WHERE "Aro"."lft" >=  '2'"
>
> I've already posted a bug to trac.cakephp.org... the reason for this
> message is that I would like to ask everybody for help on creating
> some quick solution or patch for this problem.
>
> P.S. This problem with aliases isn't just a one time thing, it is and
> will be happening until cakephp developers move the method
> renderStatement from dbo_source.php to each dbo file. It should work
> as it is, but it doesn't, they should all follow SQL standards but
> they don't. So, my suggestion is to make renderStatement in every dbo.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to