[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 03/16: Bug in function save
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 03/16: Bug in function save |
Date: |
Tue, 18 Nov 2014 01:09:01 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 6ffa7736925b1ec1f3ee699ce37d96b0b603cdde
Author: Dany De Bontridder <address@hidden>
Date: Tue Nov 18 00:18:24 2014 +0100
Bug in function save
---
include/class_noalyss_sql.php | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/include/class_noalyss_sql.php b/include/class_noalyss_sql.php
index 8c1aad5..b05cb38 100644
--- a/include/class_noalyss_sql.php
+++ b/include/class_noalyss_sql.php
@@ -87,11 +87,15 @@ abstract class Noalyss_SQL
/* load it */
if ($p_id != -1 )$this->load();
}
-
+/**
+ * Insert or update : if the row already exists, update otherwise insert
+ */
public function save()
{
$pk=$this->primary_key;
- if ($this->$pk==-1)
+ $count=$this->cn->get_value('select count(*) from '.$this->table.'
where '.$this->primary_key.'=$1',array($this->$pk));
+
+ if ($count == 0)
$this->insert();
else
$this->update();
@@ -226,7 +230,10 @@ abstract class Noalyss_SQL
{
return var_export($this, true);
}
-
+/**
+ * @todo ajout vérification type (date, text ou numeric)
+ * @return int
+ */
public function verify()
{
foreach ($this->name as $key)
@@ -317,6 +324,10 @@ abstract class Noalyss_SQL
}
return $a_return;
}
+ public function count($p_where="",$p_array=null) {
+ $count=$this->cn->get_value("select count(*) from
$this->table".$p_where,$p_array);
+ return $count;
+ }
}
?>
- [Noalyss-commit] [noalyss] branch master updated (3ab5669 -> 4a3e79e), Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 01/16: Task #1045 - Amélioration apparence : Gestion Cache les check quand on ferme la fenêtre, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 03/16: Bug in function save,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 04/16: Task #1045 - Amélioration apparence : Placement Box menu, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 02/16: Task #1045 - Amélioration apparence : Configuration Menu : ajout des tabs, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 05/16: Remove global, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 09/16: Task #1045 - Amélioration apparence : Improve window detail op, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 06/16: Adapt change for class_extension.php, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 08/16: Adapt change for class_extension.php, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 11/16: Task #1045 - Amélioration apparence : Improve apparence profie, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 12/16: profile_menu Extends profile_menu_sql, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 10/16: Task #1045 - Amélioration apparence :, Dany De Bontridder, 2014/11/17
- [Noalyss-commit] [noalyss] 13/16: class_menu_ref_sql add column me_description_etendue, Dany De Bontridder, 2014/11/17