]> git.agnieray.net Git - galette.git/commitdiff
Use prepared statement rather than direct SQL
authorJohan Cwiklinski <johan@x-tnd.be>
Tue, 9 Nov 2021 17:55:23 +0000 (18:55 +0100)
committerJohan Cwiklinski <trasher@x-tnd.be>
Tue, 9 Nov 2021 21:47:22 +0000 (22:47 +0100)
20 files changed:
galette/lib/Galette/Core/Db.php
galette/lib/Galette/Core/Logo.php
galette/lib/Galette/Core/MailingHistory.php
galette/lib/Galette/Core/Password.php
galette/lib/Galette/Core/Picture.php
galette/lib/Galette/DynamicFields/DynamicField.php
galette/lib/Galette/Entity/Adherent.php
galette/lib/Galette/Entity/Contribution.php
galette/lib/Galette/Entity/Entitled.php
galette/lib/Galette/Entity/Group.php
galette/lib/Galette/Entity/ImportModel.php
galette/lib/Galette/Entity/PaymentType.php
galette/lib/Galette/Entity/PdfModel.php
galette/lib/Galette/Entity/Reminder.php
galette/lib/Galette/Entity/SavedSearch.php
galette/lib/Galette/Entity/Social.php
galette/lib/Galette/Entity/Title.php
galette/lib/Galette/Entity/Transaction.php
galette/lib/Galette/Repository/Groups.php
galette/lib/Galette/Repository/Members.php

index ef45d7b750db62025d1c9ffa91a496b6d71a044e..1fc4d5a76efa99071599465e77b9b1d81cd5996e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2011-2014 The Galette Team
+ * Copyright © 2011-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2011-07-27
@@ -58,7 +58,7 @@ use Laminas\Db\Sql\SqlInterface;
  * @name      Db
  * @package   Galette
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://framework.zend.com/apidoc/2.2/namespaces/Zend.Db.html
  * @since     Available since 0.7dev - 2011-07-27
@@ -453,7 +453,7 @@ class Db
                 //can Galette SELECT records ?
                 try {
                     $select = $this->sql->select('galette_test');
-                    $select->where('test_id = 1');
+                    $select->where(['test_id' => 1]);
                     $res = $this->execute($select);
                     $pass = $res->count() === 1;
 
@@ -673,7 +673,7 @@ class Db
 
                 //build where
                 foreach ($pkeys as $k) {
-                    $where[] = $k . ' = "' . $row->$k . '"';
+                    $where[$k] = $row->$k;
                 }
 
                 //build data
index c03e8dd625d85bcb44ab1b49074e2fdf27c46421..a6e22417707abd0b5fd13f70a6042e7703517fd1 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2009-2014 The Galette Team
+ * Copyright © 2009-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2009-2014 The Galette Team
+ * @copyright 2009-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2009-09-13
@@ -46,7 +46,7 @@ use Analog\Analog;
  * @name      Logo
  * @package   Galette
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2009-2014 The Galette Team
+ * @copyright 2009-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2009-09-13
@@ -100,7 +100,7 @@ class Logo extends Picture
                 'format'
             )
         );
-        $select->where(self::PK . ' = ' . $this->db_id);
+        $select->where([self::PK => $this->db_id]);
         return $select;
     }
 
index 34e2bd3fa7d1b869dc64dedb036034f8f942449b..9a3e8d45ffe19461f28f28100fe730d1dbf1ea33 100644 (file)
@@ -356,7 +356,7 @@ class MailingHistory extends History
     {
         try {
             $select = $zdb->select(self::TABLE);
-            $select->where('mailing_id = ' . $id);
+            $select->where(['mailing_id' => $id]);
 
             $results = $zdb->execute($select);
             $result = $results->current();
@@ -450,7 +450,7 @@ class MailingHistory extends History
 
             $update = $this->zdb->update(self::TABLE);
             $update->set($values);
-            $update->where(self::PK . ' = ' . $this->mailing->history_id);
+            $update->where([self::PK => $this->mailing->history_id]);
             $this->zdb->execute($update);
             return true;
         } catch (Throwable $e) {
index 1832e37bdd5ae024c9bbd4424d56c5d022408d5c..728669dd170a182b2b30afbd1f2b0aaba32ec6db 100644 (file)
@@ -8,7 +8,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2003-2020 The Galette Team
+ * Copyright © 2003-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -31,7 +31,7 @@
  * @author    Frédéric Jacquot <unknown@unknow.com>
  * @author    Georges Khaznadar (password encryption, images) <unknown@unknow.com>
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2003-2014 The Galette Team
+ * @copyright 2003-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2009-02-28
@@ -52,7 +52,7 @@ use Galette\Entity\Adherent;
  * @author    Frédéric Jacquot <unknown@unknow.com>
  * @author    Georges Khaznadar (password encryption, images) <unknown@unknow.com>
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2009-2020 The Galette Team
+ * @copyright 2009-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2011-06-16
@@ -95,7 +95,7 @@ class Password extends AbstractPassword
     {
         try {
             $delete = $this->zdb->delete(self::TABLE);
-            $delete->where(self::PK . ' = ' . $id_adh);
+            $delete->where([self::PK => $id_adh]);
 
             $del = $this->zdb->execute($delete);
             if ($del) {
index 37091d462c11e72a8c432dc6dc36a06dc97664a6..4ae2eafee356758ac7dd84ff2bc753678f4f280e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2006-2014 The Galette Team
+ * Copyright © 2006-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -29,7 +29,7 @@
  *
  * @author    Frédéric Jacquot <unknown@unknow.com>
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2006-2014 The Galette Team
+ * @copyright 2006-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  */
@@ -51,7 +51,7 @@ use Galette\IO\FileTrait;
  * @package   Galette
  * @author    Frédéric Jacquot <unknown@unknow.com>
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2006-2014 The Galette Team
+ * @copyright 2006-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  */
@@ -339,9 +339,7 @@ class Picture implements FileInterface
             }
 
             $delete = $zdb->delete($this->tbl_prefix . $class::TABLE);
-            $delete->where(
-                $class::PK . ' = ' . $this->db_id
-            );
+            $delete->where([$class::PK => $this->db_id]);
             $del = $zdb->execute($delete);
 
             if (!$del->count() > 0) {
index 775ed2c53443cba1631ffe701ee8063ab88a4c42..d87aba0ce2e2e689583067b112df28a4d8f78ef1 100644 (file)
@@ -143,7 +143,7 @@ abstract class DynamicField
     {
         try {
             $select = $zdb->select(self::TABLE);
-            $select->where('field_id = ' . $id);
+            $select->where(['field_id' => $id]);
 
             $results = $zdb->execute($select);
             $result = $results->current();
@@ -216,7 +216,7 @@ abstract class DynamicField
     {
         try {
             $select = $this->zdb->select(self::TABLE);
-            $select->where(self::PK . ' = ' . $id);
+            $select->where([self::PK => $id]);
 
             $results = $this->zdb->execute($select);
             $result = $results->current();
@@ -716,9 +716,7 @@ abstract class DynamicField
 
             if (!$isnew) {
                 $update = $this->zdb->update(self::TABLE);
-                $update->set($values)->where(
-                    self::PK . ' = ' . $this->id
-                );
+                $update->set($values)->where([self::PK => $this->id]);
                 $this->zdb->execute($update);
             } else {
                 $values['field_type'] = $this->getType();
index c0344ad00cb2d083b17a19cf9500625821f4fba5..2113b6a55f3fa1f8c6af73bb39728450f60527bb 100644 (file)
@@ -473,9 +473,7 @@ class Adherent
             $select = $this->zdb->select(self::TABLE);
             $select->columns(
                 array($id)
-            )->where(
-                'parent_id = ' . $this->_id
-            );
+            )->where(['parent_id' => $this->_id]);
 
             $results = $this->zdb->execute($select);
 
@@ -847,7 +845,7 @@ class Adherent
     {
         try {
             $select = $zdb->select(self::TABLE);
-            $select->where(self::PK . ' = ' . $id);
+            $select->where([self::PK => $id]);
 
             $results = $zdb->execute($select);
             $row = $results->current();
@@ -925,7 +923,7 @@ class Adherent
             $update = $zdb->update(self::TABLE);
             $update->set(
                 array('mdp_adh' => $cpass)
-            )->where(self::PK . ' = ' . $id_adh);
+            )->where([self::PK => $id_adh]);
             $zdb->execute($update);
             Analog::log(
                 'Password for `' . $id_adh . '` has been updated.',
@@ -1307,8 +1305,9 @@ class Adherent
                             array(self::PK)
                         )->where(array('email_adh' => $value));
                         if (!empty($this->_id)) {
-                            $select->where(
-                                self::PK . ' != ' . $this->_id
+                            $select->where->notEqualTo(
+                                self::PK,
+                                $this->_id
                             );
                         }
 
@@ -1345,8 +1344,9 @@ class Adherent
                                 array(self::PK)
                             )->where(array('login_adh' => $value));
                             if (!empty($this->_id)) {
-                                $select->where(
-                                    self::PK . ' != ' . $this->_id
+                                $select->where->notEqualTo(
+                                    self::PK,
+                                    $this->_id
                                 );
                             }
 
@@ -1404,7 +1404,7 @@ class Adherent
                     $this->$prop = (int)$value;
                     //check if status exists
                     $select = $this->zdb->select(Status::TABLE);
-                    $select->where(Status::PK . '= ' . $value);
+                    $select->where([Status::PK => $value]);
 
                     $results = $this->zdb->execute($select);
                     $result = $results->current();
@@ -1577,9 +1577,7 @@ class Adherent
 
                 $update = $this->zdb->update(self::TABLE);
                 $update->set($values);
-                $update->where(
-                    self::PK . '=' . $this->_id
-                );
+                $update->where([self::PK => $this->_id]);
 
                 $edit = $this->zdb->execute($update);
 
@@ -1629,7 +1627,7 @@ class Adherent
             $update = $this->zdb->update(self::TABLE);
             $update->set(
                 array('date_modif_adh' => $modif_date)
-            )->where(self::PK . '=' . $this->_id);
+            )->where([self::PK => $this->_id]);
 
             $edit = $this->zdb->execute($update);
             $this->_modification_date = $modif_date;
index 9c088519addff2a4975de139f0f2af6be8ae85c2..c1fb4de13e6f65954e98739685276733ce4f7b23 100644 (file)
@@ -579,7 +579,7 @@ class Contribution
                 array('ct' => PREFIX_DB . ContributionsTypes::TABLE),
                 'c.' . ContributionsTypes::PK . '=ct.' . ContributionsTypes::PK,
                 array()
-            )->where(Adherent::PK . ' = ' . $this->_member)
+            )->where([Adherent::PK => $this->_member])
                 ->where(array('cotis_extension' => new Expression('true')))
                 ->where->nest->nest
                 ->greaterThanOrEqualTo('date_debut_cotis', $this->_begin_date)
@@ -590,7 +590,7 @@ class Contribution
                 ->lessThanOrEqualTo('date_fin_cotis', $this->_end_date);
 
             if ($this->id != '') {
-                $select->where(self::PK . ' != ' . $this->id);
+                $select->where->notEqualTo(self::PK, $this->id);
             }
 
             $results = $this->zdb->execute($select);
@@ -681,9 +681,7 @@ class Contribution
             } else {
                 //we're editing an existing contribution
                 $update = $this->zdb->update(self::TABLE);
-                $update->set($values)->where(
-                    self::PK . '=' . $this->_id
-                );
+                $update->set($values)->where([self::PK => $this->_id]);
                 $edit = $this->zdb->execute($update);
 
                 //edit == 0 does not mean there were an error, but that there
@@ -750,7 +748,7 @@ class Contribution
             $update->set(
                 array('date_echeance' => $date_fin_update)
             )->where(
-                Adherent::PK . '=' . $this->_member
+                [Adherent::PK => $this->_member]
             );
             $this->zdb->execute($update);
             return true;
@@ -782,7 +780,7 @@ class Contribution
             }
 
             $delete = $this->zdb->delete(self::TABLE);
-            $delete->where(self::PK . ' = ' . $this->_id);
+            $delete->where([self::PK => $this->_id]);
             $del = $this->zdb->execute($delete);
             if ($del->count() > 0) {
                 $this->updateDeadline();
@@ -884,7 +882,7 @@ class Contribution
                 'c.' . ContributionsTypes::PK . '=ct.' . ContributionsTypes::PK,
                 array()
             )->where(
-                Adherent::PK . ' = ' . $member_id
+                [Adherent::PK => $member_id]
             )->where(
                 array('cotis_extension' => new Expression('true'))
             );
@@ -927,7 +925,7 @@ class Contribution
                 $update->set(
                     array(Transaction::PK => null)
                 )->where(
-                    self::PK . ' = ' . $contrib_id
+                    [self::PK => $contrib_id]
                 );
                 $zdb->execute($update);
                 return true;
@@ -964,7 +962,7 @@ class Contribution
             $update = $zdb->update(self::TABLE);
             $update->set(
                 array(Transaction::PK => $trans_id)
-            )->where(self::PK . ' = ' . $contrib_id);
+            )->where([self::PK => $contrib_id]);
 
             $zdb->execute($update);
             return true;
index f59a1f88b7ea7909a564a7b4b9748c8eb9de7c48..20e71edbb5261c94e0c1d63166c285ce343c5632 100644 (file)
@@ -126,7 +126,7 @@ abstract class Entitled
     {
         try {
             $select = $this->zdb->select($this->table);
-            $select->where($this->fpk . ' = ' . $id);
+            $select->where([$this->fpk => $id]);
 
             $results = $this->zdb->execute($select);
             if ($results->count() > 0) {
@@ -345,7 +345,7 @@ abstract class Entitled
 
         try {
             $select = $this->zdb->select($this->table);
-            $select->where($this->fpk . '=' . $id);
+            $select->where([$this->fpk => $id]);
 
             $results = $this->zdb->execute($select);
             $result = $results->current();
@@ -507,7 +507,7 @@ abstract class Entitled
 
             $update = $this->zdb->update($this->table);
             $update->set($values);
-            $update->where($this->fpk . ' = ' . $id);
+            $update->where([$this->fpk => $id]);
 
             $ret = $this->zdb->execute($update);
 
@@ -556,7 +556,7 @@ abstract class Entitled
         try {
             $this->zdb->connection->beginTransaction();
             $delete = $this->zdb->delete($this->table);
-            $delete->where($this->fpk . ' = ' . $id);
+            $delete->where([$this->fpk => $id]);
 
             $this->zdb->execute($delete);
             $this->deleteTranslation($ret->{$this->flabel});
@@ -590,7 +590,7 @@ abstract class Entitled
     {
         try {
             $select = $this->zdb->select($this->used);
-            $select->where($this->fpk . ' = ' . $id);
+            $select->where([$this->fpk => $id]);
 
             $results = $this->zdb->execute($select);
             $result = $results->current();
index 088a5f29cb67c34165b8a2896f307745936b5ed4..8603ad8fb33361522a635fc2789703cce363cb9f 100644 (file)
@@ -179,9 +179,9 @@ class Group
                     array('g' => $join),
                     'g.' . Adherent::PK . '=a.' . Adherent::PK,
                     array()
-                )->where(
-                    'g.' . self::PK . ' = ' . $this->id
-                )->order(
+                )->where([
+                    'g.' . self::PK => $this->id
+                ])->order(
                     'nom_adh ASC',
                     'prenom_adh ASC'
                 );
@@ -231,10 +231,10 @@ class Group
                     array('b' => PREFIX_DB . self::GROUPSMANAGERS_TABLE),
                     'a.' . self::PK . '=b.' . self::PK,
                     array()
-                )->where('b.' . Adherent::PK . ' = ' . $this->login->id);
+                )->where(['b.' . Adherent::PK => $this->login->id]);
             }
 
-            $select->where('parent_group = ' . $this->id)
+            $select->where(['parent_group' => $this->id])
                 ->order('group_name ASC');
 
             $results = $zdb->execute($select);
@@ -295,24 +295,18 @@ class Group
 
                 //delete members
                 $delete = $zdb->delete(self::GROUPSUSERS_TABLE);
-                $delete->where(
-                    self::PK . ' = ' . $this->id
-                );
+                $delete->where([self::PK => $this->id]);
                 $zdb->execute($delete);
 
                 //delete managers
                 $delete = $zdb->delete(self::GROUPSMANAGERS_TABLE);
-                $delete->where(
-                    self::PK . ' = ' . $this->id
-                );
+                $delete->where([self::PK => $this->id]);
                 $zdb->execute($delete);
             }
 
             //delete group itself
             $delete = $zdb->delete(self::TABLE);
-            $delete->where(
-                self::PK . ' = ' . $this->id
-            );
+            $delete->where([self::PK => $this->id]);
             $zdb->execute($delete);
 
             //commit all changes
@@ -371,7 +365,7 @@ class Group
             $update->set(
                 array('parent_group' => new Expression('NULL'))
             )->where(
-                self::PK . ' = ' . $this->id
+                [self::PK => $this->id]
             );
 
             $edit = $zdb->execute($update);
@@ -447,7 +441,7 @@ class Group
                 $update = $zdb->update(self::TABLE);
                 $update
                     ->set($values)
-                    ->where(self::PK . '=' . $this->id);
+                    ->where([self::PK => $this->id]);
 
                 $edit = $zdb->execute($update);
 
@@ -728,9 +722,7 @@ class Group
 
             //first, remove current groups members
             $delete = $zdb->delete(self::GROUPSUSERS_TABLE);
-            $delete->where(
-                self::PK . ' = ' . $this->id
-            );
+            $delete->where([self::PK => $this->id]);
             $zdb->execute($delete);
 
             Analog::log(
@@ -818,9 +810,7 @@ class Group
 
             //first, remove current groups managers
             $delete = $zdb->delete(self::GROUPSMANAGERS_TABLE);
-            $delete->where(
-                self::PK . ' = ' . $this->id
-            );
+            $delete->where([self::PK => $this->id]);
             $zdb->execute($delete);
 
             Analog::log(
index 1c79023c1ada3dd70d5a610d437cee13ce78d4f9..4b7f1d6b8c981aa27a8a029d34d0ee56ca12cc7c 100644 (file)
@@ -175,7 +175,7 @@ class ImportModel
                 //we're editing an existing model
                 $update = $zdb->update(self::TABLE);
                 $update->set($values);
-                $update->where(self::PK . '=' . $this->id);
+                $update->where([self::PK => $this->id]);
                 $zdb->execute($update);
                 return true;
             }
index 5d0d728643a783bde2c5554e32b918f4bf1ee325..d5a1117768ecb2efb3dfdb81be5c81273955aef3 100644 (file)
@@ -100,7 +100,7 @@ class PaymentType
     {
         try {
             $select = $this->zdb->select(self::TABLE);
-            $select->limit(1)->where(self::PK . ' = ' . $id);
+            $select->limit(1)->where([self::PK => $id]);
 
             $results = $this->zdb->execute($select);
             $res = $results->current();
@@ -149,9 +149,7 @@ class PaymentType
                 }
 
                 $update = $this->zdb->update(self::TABLE);
-                $update->set($data)->where(
-                    self::PK . '=' . $this->id
-                );
+                $update->set($data)->where([self::PK => $this->id]);
                 $this->zdb->execute($update);
             } else {
                 $insert = $this->zdb->insert(self::TABLE);
@@ -191,9 +189,7 @@ class PaymentType
 
         try {
             $delete = $this->zdb->delete(self::TABLE);
-            $delete->where(
-                self::PK . ' = ' . $id
-            );
+            $delete->where([self::PK => $id]);
             $this->zdb->execute($delete);
             $this->deleteTranslation($this->name);
             Analog::log(
index 49219641983b9116bb67630dd2333d3244381dd7..ba559f82b1c67f24fb60b390c779d088bdae7e2c 100644 (file)
@@ -136,7 +136,7 @@ abstract class PdfModel
         try {
             $select = $this->zdb->select(self::TABLE);
             $select->limit(1)
-                ->where(self::PK . ' = ' . $id);
+                ->where([self::PK => $id]);
 
             $results = $this->zdb->execute($select);
 
@@ -231,7 +231,7 @@ abstract class PdfModel
             if ($this->id !== null) {
                 $update = $this->zdb->update(self::TABLE);
                 $update->set($data)->where(
-                    self::PK . '=' . $this->id
+                    [self::PK => $this->id]
                 );
                 $this->zdb->execute($update);
             } else {
index c949aef84a766c1a31f827a922a7fb556c16e74a..e7443c615093f43dd1db9c9321d2cd9621377447 100644 (file)
@@ -111,7 +111,7 @@ class Reminder
         try {
             $select = $zdb->select(self::TABLE);
             $select->limit(1)
-                ->where(self::PK . ' = ' . $id);
+                ->where([self::PK => $id]);
 
             $results = $zdb->execute($select);
             $this->loadFromRs($results->current());
index 2452a3e9a2cf1f2bfd66b3535914242b77df8944..3dba26aa8fae95cf09cc35f7931e688372d1e056 100644 (file)
@@ -102,11 +102,11 @@ class SavedSearch
     {
         try {
             $select = $this->zdb->select(self::TABLE);
-            $select->limit(1)->where(self::PK . ' = ' . $id);
+            $select->limit(1)->where([self::PK => $id]);
             if ($this->login->isSuperAdmin()) {
                 $select->where(Adherent::PK . ' IS NULL');
             } else {
-                $select->where(Adherent::PK . ' = ' . (int)$this->login->id);
+                $select->where([Adherent::PK => $this->login->id]);
             }
 
             $results = $this->zdb->execute($select);
@@ -223,9 +223,7 @@ class SavedSearch
         $id = (int)$this->id;
         try {
             $delete = $this->zdb->delete(self::TABLE);
-            $delete->where(
-                self::PK . ' = ' . $id
-            );
+            $delete->where([self::PK => $id]);
             $this->zdb->execute($delete);
             Analog::log(
                 'Saved search #' . $id . ' (' . $this->name
index 1084bb3e171385601f3f6703b72b2ec9dd58f5be..1c4bceedaf470801b30bdb1122a18a05474dd335 100644 (file)
@@ -114,7 +114,7 @@ class Social
     {
         try {
             $select = $this->zdb->select(self::TABLE);
-            $select->limit(1)->where(self::PK . ' = ' . $id);
+            $select->limit(1)->where([self::PK => $id]);
 
             $results = $this->zdb->execute($select);
             $res = $results->current();
@@ -199,7 +199,7 @@ class Social
             if ($this->id !== null && $this->id > 0) {
                 $update = $this->zdb->update(self::TABLE);
                 $update->set(['url' => $this->url])->where(
-                    self::PK . '=' . $this->id
+                    [self::PK => $this->id]
                 );
                 $this->zdb->execute($update);
             } else {
index 1fb7a41adb159b42b40ac3f5508ca7b44266f796..3218522f0947e7e95223b0e178abae090ad6ba17 100644 (file)
@@ -91,7 +91,7 @@ class Title
         global $zdb;
         try {
             $select = $zdb->select(self::TABLE);
-            $select->limit(1)->where(self::PK . ' = ' . $id);
+            $select->limit(1)->where([self::PK => $id]);
 
             $results = $zdb->execute($select);
             $res = $results->current();
@@ -145,9 +145,7 @@ class Title
         try {
             if ($this->id !== null && $this->id > 0) {
                 $update = $zdb->update(self::TABLE);
-                $update->set($data)->where(
-                    self::PK . '=' . $this->id
-                );
+                $update->set($data)->where([self::PK => $this->id]);
                 $zdb->execute($update);
             } else {
                 $insert = $zdb->insert(self::TABLE);
@@ -187,9 +185,7 @@ class Title
 
         try {
             $delete = $zdb->delete(self::TABLE);
-            $delete->where(
-                self::PK . ' = ' . $id
-            );
+            $delete->where([self::PK => $id]);
             $zdb->execute($delete);
             Analog::log(
                 'Title #' . $id . ' (' . $this->short
index 321db6e38504d75bb5a25ba0f76527f8662fe7bf..08caee36c5379e7b7f0d4c35dbddfb66bd67c704 100644 (file)
@@ -154,7 +154,7 @@ class Transaction
     {
         try {
             $select = $this->zdb->select(self::TABLE, 't');
-            $select->where(self::PK . ' = ' . $id);
+            $select->where([self::PK => $id]);
             $select->join(
                 array('a' => PREFIX_DB . Adherent::TABLE),
                 't.' . Adherent::PK . '=a.' . Adherent::PK,
@@ -235,9 +235,7 @@ class Transaction
 
             //remove transaction itself
             $delete = $this->zdb->delete(self::TABLE);
-            $delete->where(
-                self::PK . ' = ' . $this->_id
-            );
+            $delete->where([self::PK => $this->_id]);
             $del = $this->zdb->execute($delete);
             if ($del->count() > 0) {
                 $this->dynamicsRemove(true);
@@ -457,9 +455,7 @@ class Transaction
             } else {
                 //we're editing an existing transaction
                 $update = $this->zdb->update(self::TABLE);
-                $update->set($values)->where(
-                    self::PK . '=' . $this->_id
-                );
+                $update->set($values)->where([self::PK => $this->_id]);
                 $edit = $this->zdb->execute($update);
                 //edit == 0 does not mean there were an error, but that there
                 //were nothing to change
@@ -514,7 +510,7 @@ class Transaction
                 array(
                     'sum' => new Expression('SUM(montant_cotis)')
                 )
-            )->where(self::PK . ' = ' . $this->_id);
+            )->where([self::PK => $this->_id]);
 
             $results = $this->zdb->execute($select);
             $result = $results->current();
@@ -547,7 +543,7 @@ class Transaction
                 array(
                     'sum' => new Expression('SUM(montant_cotis)')
                 )
-            )->where(self::PK . ' = ' . $this->_id);
+            )->where([self::PK => $this->_id]);
 
             $results = $this->zdb->execute($select);
             $result = $results->current();
index 5fa8cf987a06a5ba8e45227768feda4f3abdfc4f..9839f6db86a0499889f09d36b29b1d1dbee5ae00 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2011-2014 The Galette Team
+ * Copyright © 2011-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2011-10-25
@@ -52,7 +52,7 @@ use Galette\Core\Db;
  * @name      Groups
  * @package   Galette
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7dev - 2011-10-25
@@ -136,7 +136,7 @@ class Groups
                     array('c' => PREFIX_DB . Group::GROUPSMANAGERS_TABLE),
                     'a.' . Group::PK . '=c.' . Group::PK,
                     array()
-                )->where('c.' . Adherent::PK . ' = ' . $this->login->id);
+                )->where(['c.' . Adherent::PK => $this->login->id]);
             }
 
             if ($full !== true) {
@@ -275,9 +275,7 @@ class Groups
 
             //first, remove current groups members
             $delete = $zdb->delete($table);
-            $delete->where(
-                Adherent::PK . ' = ' . $adh->id
-            );
+            $delete->where([Adherent::PK => $adh->id]);
             $zdb->execute($delete);
 
             $msg = null;
index 424fea671aa6066ef4409f580e3347a20b24b1d4..235cabe668f9d0fda48ed95e464c53854de5cd2b 100644 (file)
@@ -641,7 +641,7 @@ class Members
                         array('m' => PREFIX_DB . Group::GROUPSMANAGERS_TABLE),
                         'gr.' . Group::PK . '=m.' . Group::PK,
                         array()
-                    )->where('m.' . Adherent::PK . ' = ' . $login->id);
+                    )->where(['m.' . Adherent::PK => $login->id]);
                     break;
                 case self::SHOW_PUBLIC_LIST:
                     if ($photos) {
@@ -731,8 +731,8 @@ class Members
                             'val'       => 'field_val'
                         ]
                     );
-                    $subselect->where('df.field_form = \'adh\'');
-                    $subselect->where('df.field_id = ' . $df);
+                    $subselect->where(['df.field_form' => 'adh']);
+                    $subselect->where(['df.field_id' => $df]);
                     $select->join(
                         array('df' . $df => $subselect),
                         'a.id_adh = df' . $df . '.item_id',
@@ -1155,7 +1155,7 @@ class Members
                     array(),
                     $select::JOIN_LEFT
                 )->where(
-                    '(g.' . Group::PK . ' = ' . $this->filters->group_filter .
+                    '(g.' . Group::PK . ' = ' . $zdb->platform->quoteValue($this->filters->group_filter) .
                     ' OR gs.parent_group = NULL OR gs.parent_group = ' .
                     $this->filters->group_filter . ')'
                 );