noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Single_Record Class Reference

Objec to check a double insert into the database, this duplicate occurs after a refresh of the web page in. More...

+ Collaboration diagram for Single_Record:

Public Member Functions

 __construct ($p_name)
 Constructor $p_name will be set to $this->name, it is also the name of the tag hidden in a form.
 
 check ($p_array=null)
 
 get_count ($p_array=null)
 Count how many time we have this->id into the table tool_uos.
 
 hidden ()
 return a string with a tag hidden and a uniq value
 
 save ($p_array=null)
 Try to insert into the table Single_Record.
 

Data Fields

 $id
 
 $name
 

Detailed Description

Objec to check a double insert into the database, this duplicate occurs after a refresh of the web page in.

Definition at line 33 of file single_record.class.php.

Constructor & Destructor Documentation

◆ __construct()

Single_Record::__construct ( $p_name)

Constructor $p_name will be set to $this->name, it is also the name of the tag hidden in a form.

Remarks
$cn Db connexion
Parameters
$p_name

Definition at line 43 of file single_record.class.php.

44 {
45 $this->name=$p_name;
46 }
$from_poste name

References name.

Member Function Documentation

◆ check()

Single_Record::check ( $p_array = null)

Definition at line 92 of file single_record.class.php.

93 {
94 global $cn;
95 if ( $p_array == null ) $p_array=$_POST;
96 $this->id=$p_array[$this->name];
97 try
98 {
99 $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
100 array($this->id));
101 if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
102 }catch (Exception $e)
103 {
104 throw $e;
105 }
106 }
$_POST['ac']
Definition do.php:312
$count
const CODE_EXCP_DUPLICATE

References $_POST, $cn, $count, $e, $name, $p_array, and CODE_EXCP_DUPLICATE.

◆ get_count()

Single_Record::get_count ( $p_array = null)

Count how many time we have this->id into the table tool_uos.

Remarks
global $cn Database connexion
Parameters
$p_arrayis the array where to find the key name, usually it is $_POST. The default value is $_POST
Returns
integer : 0 or 1

Definition at line 83 of file single_record.class.php.

84 {
85 global $cn;
86 if ( $p_array == null ) $p_array=$_POST;
87 $this->id=$p_array[$this->name];
88 $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
89 array($this->id));
90 return $count;
91 }

References $_POST, $cn, $count, $name, and $p_array.

◆ hidden()

Single_Record::hidden ( )

return a string with a tag hidden and a uniq value

Parameters
$hHiddenis the name of the tag hidden
Returns
string : tag hidden

Definition at line 52 of file single_record.class.php.

53 {
54 global $cn;
55 $this->id=$cn->get_next_seq('uos_pk_seq');
56 return HtmlInput::hidden($this->name,$this->id);
57 }
static hidden($p_name, $p_value, $p_id="")

References $cn, and name.

◆ save()

Single_Record::save ( $p_array = null)

Try to insert into the table Single_Record.

Remarks
global $cn Database connexion
Exceptions
Exceptionif the value $p_id is not unique

Definition at line 63 of file single_record.class.php.

64 {
65 global $cn;
66 if ( $p_array == null ) $p_array=$_POST;
67 $this->id=$p_array[$this->name];
68 $sql="insert into tool_uos(uos_value) values ($1)";
69 try {
70 $cn->exec_sql($sql,array($this->id));
71 } catch (Exception $e)
72 {
73 throw new Exception('Duplicate value');
74 }
75 }

References $_POST, $cn, $e, $name, $p_array, and $sql.

Field Documentation

◆ $id

Single_Record::$id

Definition at line 36 of file single_record.class.php.

◆ $name

Single_Record::$name

Definition at line 35 of file single_record.class.php.

Referenced by check(), get_count(), and save().


The documentation for this class was generated from the following file: