Bonjour,

Voici un patch remplaçant les requêtes comportant encore un delete multitable dans contrat.class.php par du code php équivalent, afin de les rendre compatible avec Mysql 3.2.


--
*Raphaël Bertrand*
Résultic - Management & Informatique
Siège : 11 rue Tronchet - 69006 LYON
Bureaux : 11 pl Maréchal Lyautey - 69006 LYON
Fixe. 08 74 77 00 70
Fax. 08 25 24 85 02
E-Mail : [EMAIL PROTECTED]
Index: contrat.class.php
===================================================================
RCS file: /sources/dolibarr/dolibarr/htdocs/contrat/contrat.class.php,v
retrieving revision 1.104
diff -u -r1.104 contrat.class.php
--- contrat.class.php   1 Jun 2008 16:31:03 -0000       1.104
+++ contrat.class.php   20 Jun 2008 14:20:35 -0000
@@ -2,6 +2,7 @@
 /* Copyright (C) 2003      Rodolphe Quiedeville <[EMAIL PROTECTED]>
  * Copyright (C) 2004-2007 Destailleur Laurent  <[EMAIL PROTECTED]>
  * Copyright (C) 2006      Andre Cianfarani     <[EMAIL PROTECTED]>
+ * Copyright (C) 2008 Raphael Bertrand (Resultic)       <[EMAIL PROTECTED]>
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -572,35 +573,92 @@
         if (! $error)
         {
                        // Delete element_contact
+                       /*
                        $sql = "DELETE ec";
                        $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, 
".MAIN_DB_PREFIX."c_type_contact as tc";
                $sql.= " WHERE ec.fk_c_type_contact = tc.rowid";
                        $sql.= " AND tc.element='".$this->element."'";
                        $sql.= " AND ec.element_id=".$this->id;
-
+                       */
+                       
+                       $sql = "SELECT ec.rowid as ecrowid";
+                       $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, 
".MAIN_DB_PREFIX."c_type_contact as tc";
+               $sql.= " WHERE ec.fk_c_type_contact = tc.rowid";
+                       $sql.= " AND tc.element='".$this->element."'";
+                       $sql.= " AND ec.element_id=".$this->id;
+                       
                        dolibarr_syslog("Contrat::delete element_contact 
sql=".$sql,LOG_DEBUG);
-               $resql=$this->db->query($sql);
+                       $resql=$this->db->query($sql);
                        if (! $resql)
                        {
                                $this->error=$this->db->error();
                                $error++;
                        }
+                       $numressql=$this->db->num_rows($resql);
+                       if (! $error && $numressql )
+                       {
+                               $tab_resql=array();
+                               for($i=0;$i<$numressql;$i++)
+                               {
+                                       
$objresql=$this->db->fetch_object($resql);
+                                       $tab_resql[]= $objresql->ecrowid;
+                               }
+                               $this->db->free($resql);
+                               
+                               $sql= "DELETE FROM 
".MAIN_DB_PREFIX."element_contact ";
+                               $sql.= " WHERE 
".MAIN_DB_PREFIX."element_contact.rowid IN (".implode(",",$tab_resql).")";
+                               
+                               dolibarr_syslog("Contrat::delete 
element_contact sql=".$sql,LOG_DEBUG);
+                       $resql=$this->db->query($sql);
+                               if (! $resql)
+                               {
+                                       $this->error=$this->db->error();
+                                       $error++;
+                               }
+                       }
                }
                
         if (! $error)
         {
                        // Delete contratdet_log
+                       /*
                        $sql = "DELETE cdl";
                        $sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, 
".MAIN_DB_PREFIX."contratdet as cd";
+                       $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND 
cd.fk_contrat=".$this->id;
+                       */
+                       $sql = "SELECT cdl.rowid as cdlrowid ";
+                       $sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, 
".MAIN_DB_PREFIX."contratdet as cd";
                $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND 
cd.fk_contrat=".$this->id;
-
+                       
                        dolibarr_syslog("Contrat::delete contratdet_log 
sql=".$sql, LOG_DEBUG);
-               $resql=$this->db->query($sql);
+                       $resql=$this->db->query($sql);
                        if (! $resql)
                        {
                                $this->error=$this->db->error();
                                $error++;
                        }
+                       $numressql=$this->db->num_rows($resql);
+                       if (! $error && $numressql )
+                       {
+                               $tab_resql=array();
+                               for($i=0;$i<$numressql;$i++)
+                               {
+                                       
$objresql=$this->db->fetch_object($resql);
+                                       $tab_resql[]= $objresql->cdlrowid;
+                               }
+                               $this->db->free($resql);
+                               
+                               $sql= "DELETE FROM 
".MAIN_DB_PREFIX."contratdet_log ";
+                               $sql.= " WHERE 
".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",",$tab_resql).")";
+                       
+                               dolibarr_syslog("Contrat::delete contratdet_log 
sql=".$sql, LOG_DEBUG);
+                       $resql=$this->db->query($sql);
+                               if (! $resql)
+                               {
+                                       $this->error=$this->db->error();
+                                       $error++;
+                               }
+                       }
                }
                
         if (! $error)

_______________________________________________
Dolibarr-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/dolibarr-dev

Répondre à