noalyss Version-9
Public Member Functions | Data Fields
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. More...
 
 check ($p_array=null)
 
 get_count ($p_array=null)
 Count how many time we have this->id into the table tool_uos. More...
 
 hidden ()
 return a string with a tag hidden and a uniq value More...
 
 save ($p_array=null)
 Try to insert into the table Single_Record. More...
 

Data Fields

 $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 42 of file single_record.class.php.

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

References name.

Member Function Documentation

◆ check()

Single_Record::check (   $p_array = null)

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

92 {
93 global $cn;
94 if ( $p_array == null ) $p_array=$_POST;
95 $this->id=$p_array[$this->name];
96 try
97 {
98 $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
99 array($this->id));
100 if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
101 }catch (Exception $e)
102 {
103 throw $e;
104 }
105 }
$_POST['ac']
Definition: do.php:310
$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 82 of file single_record.class.php.

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

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 51 of file single_record.class.php.

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

References $cn, HtmlInput\hidden(), and name.

+ Here is the call graph for this function:

◆ 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 62 of file single_record.class.php.

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

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

Field Documentation

◆ $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: