[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 19/34: Documentation
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 19/34: Documentation |
Date: |
Sun, 5 Feb 2023 04:41:41 -0500 (EST) |
sparkyx pushed a commit to branch devel
in repository noalyss.
commit 1b166ea8cb5131eaa6ca3b248c8caf1268836ba9
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Jan 15 22:24:54 2023 +0100
Documentation
---
include/lib/data_sql.class.php | 53 +++++++++++++++++++++++++++++++++-
include/lib/manage_table_sql.class.php | 3 +-
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/include/lib/data_sql.class.php b/include/lib/data_sql.class.php
index 37b0bc1f5..55d0353d3 100644
--- a/include/lib/data_sql.class.php
+++ b/include/lib/data_sql.class.php
@@ -38,7 +38,31 @@
* - type = array , match between column and type of data
* - default = array of column with a default value
* - date_format = format of the date
- *
+ *
+ * if you give a SQL or a View you have to give a primary key, usually , the
best is to use a key composed of
+ * different PK of the tables
+ * Example : in this SQL (or view) the PK is id and it is composed with the PK
f_id and sg_id , remember that the
+ * pk cannot be null and must be unique ! For SQL , the value is computed , so
you need a subselect like this
+ @code
+ select
+ ssw.sg_id::text||'-'||vfp.f_id::text id,
+ vfp.f_id,vfp.f_enable,vfp.person_name ,vfp.person_fname ,vfp.person_qcode
,ssw.sg_id
+ from rash.vw_fiche_person vfp
+ join rash.security_social_worker ssw using(f_id) ;
+ @endcode
+ *
+ * For SQL , the value is computed , so you need a subselect like this
+@code
+ select * from (
+ select
+ ssw.sg_id::text||'-'||vfp.f_id::text id,
+ vfp.f_id,vfp.f_enable,vfp.person_name ,vfp.person_fname
,vfp.person_qcode ,ssw.sg_id
+ from rash.vw_fiche_person vfp
+ join rash.security_social_worker ssw using(f_id))sub1
+@encode
+ *
+ *
+ *
* After you call the parent constructor
* @note the view or the table must include an unique key, otherwise the load
* doesn't work.
@@ -199,6 +223,33 @@ abstract class Data_SQL
return $this->$pk;
}
+ /**
+ * @brief Load the current row return false if not found
+ * @code
+ $pk=$this->primary_key;
+ if ( $this->get_limit_fiche_qcode() != 0 )
+ {
+ $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
+ } else
+ {
+ $sql=sprintf($this->sql," ");
+ }
+ $result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
+ if ($this->cn->count()==0)
+ {
+ $this->$pk=-1;
+ return false;
+ }
+
+ foreach ($result[0] as $key=> $value)
+ {
+ $this->$key=$value;
+ }
+ return true;
+ *
+ * @endcode
+ * @return bool
+ */
abstract function load():bool;
public function get_info()
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index ba52307db..45cffff6f 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -31,7 +31,7 @@
\code
$objet->set_pk($p_id);
// It is very important to set the name of the javascript variable
- // Contained in the http_input variable "ctl"
+ // Contained in the http_input variable "ctl" , without this the list cannot
be updated
$objet->set_object_name($objet_name);
// Set the ajax to call
@@ -51,6 +51,7 @@
$json=json_encode($aJson);
$objet->param_set($json);
+
// Display the box
header('Content-type: text/xml; charset=UTF-8');
$xml=$objet->ajax_input();
- [Noalyss-commit] [noalyss] 18/34: Cosmetic : improve CSS for enrich text, (continued)
- [Noalyss-commit] [noalyss] 18/34: Cosmetic : improve CSS for enrich text, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 25/34: Merge branch 'devel', Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 22/34: improve code : sql : document table action_gestion, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 23/34: Documentation ManageTable.js, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 30/34: Bug #0002219: Compatibilité PHP 8.2 , 8.1 , 8.0, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 33/34: Minimum PHP 7.4, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 20/34: Fix : if there is no stock there is an exception instead of a warning, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 27/34: Bug #0002206: CA - impossible de supprimer un poste analytique, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 11/34: NEW #0002205 Mode maintenance, Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 12/34: Fix : generate_random_string returns always same value , due to a change in srand(), Dany De Bontridder, 2023/02/05
- [Noalyss-commit] [noalyss] 19/34: Documentation,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 34/34: esthetic and doc, Dany De Bontridder, 2023/02/05