[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 24/27: Noalyss_SQL Create a function build qu
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 24/27: Noalyss_SQL Create a function build query |
Date: |
Wed, 4 Sep 2019 15:24:58 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit d0b254366972beb94d738697f469ec700d3c1b8c
Author: Dany De Bontridder <address@hidden>
Date: Wed Sep 4 21:11:37 2019 +0200
Noalyss_SQL Create a function build query
---
include/lib/noalyss_sql.class.php | 46 +++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/include/lib/noalyss_sql.class.php
b/include/lib/noalyss_sql.class.php
index 0e23ca8..aa40129 100644
--- a/include/lib/noalyss_sql.class.php
+++ b/include/lib/noalyss_sql.class.php
@@ -87,6 +87,7 @@ require NOALYSS_INCLUDE."/lib/data_sql.class.php";
abstract class Noalyss_SQL extends Data_SQL
{
+ var $default;
function __construct(&$p_cn, $p_id=-1)
{
$this->cn=$p_cn;
@@ -104,6 +105,7 @@ abstract class Noalyss_SQL extends Data_SQL
$this->$pk=$p_id;
/* load it */
if ($p_id != -1 )$this->load();
+
}
/**
* Insert or update : if the row already exists, update otherwise insert
@@ -255,23 +257,8 @@ abstract class Noalyss_SQL extends Data_SQL
public function load()
{
- $sql=" select ";
- $sep="";
- foreach ($this->name as $key) {
- switch ($this->type[$key])
- {
- case "date":
- $sql .= $sep.'to_char('.$key.",'".$this->date_format."')
as ".$key;
- break;
- default:
- $sql.=$sep.$key;
- }
- $sep=",";
- }
+ $sql=$this->build_query();
$pk=$this->primary_key;
- $sql.=" from ".$this->table;
-
- $sql.=" where ".$this->primary_key." = $1";
$result=$this->cn->get_array($sql,array ($this->$pk));
if ($this->cn->count()==0)
@@ -412,6 +399,33 @@ abstract class Noalyss_SQL extends Data_SQL
$count=$this->cn->get_value("select count(*) from ".$this->table."
where ".$this->primary_key."=$1",array($this->$pk));
return $count;
}
+
+ /**
+ * Build the SQL select statement for querying the object and returns it
+ * @return string Query of the object
+ */
+ public function build_query()
+ {
+ $sql=" select ";
+ $sep="";
+ foreach ($this->name as $key) {
+ switch ($this->type[$key])
+ {
+ case "date":
+ $sql .= $sep.'to_char('.$key.",'".$this->date_format."')
as ".$key;
+ break;
+ default:
+ $sql.=$sep.$key;
+ }
+ $sep=",";
+ }
+ $pk=$this->primary_key;
+ $sql.=" from ".$this->table;
+
+ $sql.=" where ".$this->primary_key." = $1";
+
+ return $sql;
+ }
}
?>
- [Noalyss-commit] [noalyss] 19/27: #0001735: icone warning, (continued)
- [Noalyss-commit] [noalyss] 19/27: #0001735: icone warning, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 13/27: Missing files for #1369: Étendre la comptabilité analytique à tous les postes?, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 10/27: #0001711: Gros souci comptanal Montant compté en absolu, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 15/27: @0001735: icone poubelle catégorie de fiche, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 17/27: #0001735: icone poubelle catégorie de fiche, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 22/27: translate, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 23/27: Data_SQL add the member, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 16/27: #0001736: PHP7 comptability + translation, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 14/27: #0001643: ajout icon "cache" pour bouton "remonter", Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 25/27: PDF_Core : add function get, Dany De Bontridder, 2019/09/04
- [Noalyss-commit] [noalyss] 24/27: Noalyss_SQL Create a function build query,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 01/27: Cosmetic, Dany De Bontridder, 2019/09/04