Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 require_once 'class_database.php';
00027 define ('CODE_EXCP_DUPLICATE',901);
00028
00029
00030
00031
00032
00033
00034 class Tool_Uos
00035 {
00036
00037
00038
00039
00040
00041
00042 function __construct($p_name)
00043 {
00044 $this->name=$p_name;
00045 }
00046
00047
00048
00049
00050
00051 function hidden()
00052 {
00053 global $cn;
00054 $this->id=$cn->get_next_seq('uos_pk_seq');
00055 return HtmlInput::hidden($this->name,$this->id);
00056 }
00057
00058
00059
00060
00061
00062 function save($p_array=null)
00063 {
00064 global $cn;
00065 if ( $p_array == null ) $p_array=$_POST;
00066 $this->id=$p_array[$this->name];
00067 $sql="insert into tool_uos(uos_value) values ($1)";
00068 try {
00069 $cn->exec_sql($sql,array($this->id));
00070 } catch (Exception $e)
00071 {
00072 throw new Exception('Duplicate value');
00073 }
00074 }
00075
00076
00077
00078
00079
00080
00081
00082 function get_count($p_array=null)
00083 {
00084 global $cn;
00085 if ( $p_array == null ) $p_array=$_POST;
00086 $this->id=$p_array[$this->name];
00087 $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
00088 array($this->id));
00089 return $count;
00090 }
00091 function check ($p_array=null)
00092 {
00093 global $cn;
00094 if ( $p_array == null ) $p_array=$_POST;
00095 $this->id=$p_array[$this->name];
00096 try
00097 {
00098 $count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
00099 array($this->id));
00100 if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
00101 }catch (Exception $e)
00102 {
00103 throw $e;
00104 }
00105 }
00106 }
00107 ?>