noalyss Version-10
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. More...

+ Collaboration diagram for Single_Record:

Public Member Functions

 __construct ($p_name, $dbconx=-1)
 Constructor $p_name will be set to $this->name, it is also the name of the tag hidden in a form.
 
 __toString ()
 
 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
 

Private Attributes

 $dbconx
 database connexion
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

Single_Record::__construct ( $p_name,
$dbconx = -1 )

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(string) name of the HIDDEN INPUT
$dbconxDatabase connx , if not given; use global $cn;

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

45 {
46 $this->name=$p_name;
47 $this->id=0;
48 if ( is_numeric($dbconx ) ) {
49 global $cn;
50 $this->dbconx=$cn;
51 }else {
52 $this->dbconx=$dbconx;
53 }
54
55 }
$from_poste name
$dbconx
database connexion

References $cn, $dbconx, and name.

Member Function Documentation

◆ __toString()

Single_Record::__toString ( )

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

56 : string {
57 return "Single_Record[name=" . $this->name
58 . ", id=" . $this->id
59 . ", dbconx=" . $this->dbconx
60 . "]";
61 }

References id, name, and return.

◆ check()

Single_Record::check ( $p_array = null)

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

106 {
107 global $cn;
108 if ( $p_array == null ) $p_array=$_POST;
109 $this->id=$p_array[$this->name];
110 try
111 {
112 $count=$this->dbconx->get_value('select count(*) from tool_uos where uos_value=$1',
113 array($this->id));
114 if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
115 }catch (Exception $e)
116 {
117 throw $e;
118 }
119 }
$_POST['ac']
Definition do.php:323
$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 96 of file single_record.class.php.

97 {
98 global $cn;
99 if ( $p_array == null ) $p_array=$_POST;
100 $this->id=$p_array[$this->name];
101 $count=$this->dbconx->get_value('select count(*) from tool_uos where uos_value=$1',
102 array($this->id));
103 return $count;
104 }

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

68 {
69 $this->id=$this->dbconx->get_next_seq('uos_pk_seq');
70 return HtmlInput::hidden($this->name,$this->id);
71 }
static hidden($p_name, $p_value, $p_id="")

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

78 {
79 if ( $p_array == null ) $p_array=$_POST;
80 $this->id=$p_array[$this->name];
81 $sql="insert into tool_uos(uos_value) values ($1)";
82 try {
83 $this->dbconx->exec_sql($sql,array($this->id));
84 } catch (Exception $e)
85 {
86 throw new Exception('Duplicate value');
87 }
88 }

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

Field Documentation

◆ $dbconx

Single_Record::$dbconx
private

database connexion

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

Referenced by __construct().

◆ $id

Single_Record::$id

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

◆ $name

Single_Record::$name

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


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