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
00027 require_once('class_database.php');
00028 require_once('ac_common.php');
00029
00030
00031
00032
00033 class Menu_Ref_sql
00034 {
00035
00036
00037 protected $variable = array(
00038 "me_code" => "me_code"
00039 , "me_menu" => "me_menu"
00040 , "me_file" => "me_file"
00041 , "me_url" => "me_url"
00042 , "me_description" => "me_description"
00043 , "me_parameter" => "me_parameter"
00044 , "me_javascript" => "me_javascript"
00045 , "me_type" => "me_type"
00046 );
00047
00048 function __construct(& $p_cn, $p_id=-1)
00049 {
00050 $this->cn = $p_cn;
00051 $this->me_code = $p_id;
00052
00053 if ($p_id == -1)
00054 {
00055
00056 foreach ($this->variable as $key => $value)
00057 $this->$value = null;
00058 $this->me_code = $p_id;
00059 }
00060 else
00061 {
00062
00063
00064 $this->load();
00065 }
00066 }
00067
00068 public function get_parameter($p_string)
00069 {
00070 if (array_key_exists($p_string, $this->variable))
00071 {
00072 $idx = $this->variable[$p_string];
00073 return $this->$idx;
00074 }
00075 else
00076 throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant');
00077 }
00078
00079 public function set_parameter($p_string, $p_value)
00080 {
00081 if (array_key_exists($p_string, $this->variable))
00082 {
00083 $idx = $this->variable[$p_string];
00084 $this->$idx = $p_value;
00085 }
00086 else
00087 throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant');
00088 }
00089
00090 public function get_info()
00091 {
00092 return var_export($this, true);
00093 }
00094
00095 public function verify()
00096 {
00097
00098
00099 if (trim($this->me_menu) == '')
00100 $this->me_menu = null;
00101 if (trim($this->me_file) == '')
00102 $this->me_file = null;
00103 if (trim($this->me_url) == '')
00104 $this->me_url = null;
00105 if (trim($this->me_description) == '')
00106 $this->me_description = null;
00107 if (trim($this->me_parameter) == '')
00108 $this->me_parameter = null;
00109 if (trim($this->me_javascript) == '')
00110 $this->me_javascript = null;
00111 if (trim($this->me_type) == '')
00112 $this->me_type = null;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 public function seek($cond='', $p_array=null)
00124 {
00125 $sql = "select * from public.menu_ref $cond";
00126 $aobj = array();
00127 $ret = $this->cn->exec_sql($sql, $p_array);
00128 return $ret;
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 public function get_object($p_ret, $idx)
00140 {
00141
00142 $oobj = new Menu_Ref_sql($this->cn);
00143 $array = Database::fetch_array($p_ret, $idx);
00144 foreach ($array as $idx => $value)
00145 {
00146 $oobj->$idx = $value;
00147 }
00148 return $oobj;
00149 }
00150
00151 public function insert()
00152 {
00153 if ($this->verify() != 0)
00154 return;
00155
00156 $sql = "insert into public.menu_ref(me_menu
00157 ,me_file
00158 ,me_url
00159 ,me_description
00160 ,me_parameter
00161 ,me_javascript
00162 ,me_type
00163 ,me_code) values ($1
00164 ,$2
00165 ,$3
00166 ,$4
00167 ,$5
00168 ,$6
00169 ,$7
00170 ,$8
00171 ) returning me_code";
00172
00173 $this->me_code = $this->cn->get_value(
00174 $sql, array($this->me_menu
00175 , $this->me_file
00176 , $this->me_url
00177 , $this->me_description
00178 , $this->me_parameter
00179 , $this->me_javascript
00180 , $this->me_type
00181 , $this->me_code)
00182 );
00183
00184 }
00185
00186 public function update()
00187 {
00188 if ($this->verify() != 0)
00189 return;
00190
00191 $sql = " update public.menu_ref set me_menu = $1
00192 ,me_file = $2
00193 ,me_url = $3
00194 ,me_description = $4
00195 ,me_parameter = $5
00196 ,me_javascript = $6
00197 ,me_type = $7
00198 where me_code= $8";
00199 $res = $this->cn->exec_sql(
00200 $sql, array($this->me_menu
00201 , $this->me_file
00202 , $this->me_url
00203 , $this->me_description
00204 , $this->me_parameter
00205 , $this->me_javascript
00206 , $this->me_type
00207 , $this->me_code)
00208 );
00209 }
00210
00211
00212
00213
00214
00215 public function load()
00216 {
00217
00218 $sql = "select me_menu
00219 ,me_file
00220 ,me_url
00221 ,me_description
00222 ,me_parameter
00223 ,me_javascript
00224 ,me_type
00225 from public.menu_ref where me_code=$1";
00226
00227 $res = $this->cn->get_array(
00228 $sql, array($this->me_code)
00229 );
00230
00231 if (count($res) == 0)
00232 {
00233
00234 foreach ($this->variable as $key => $value)
00235 $this->$key = '';
00236
00237 return -1;
00238 }
00239 foreach ($res[0] as $idx => $value)
00240 {
00241 $this->$idx = $value;
00242 }
00243 return 0;
00244 }
00245
00246 public function delete()
00247 {
00248 $sql = "delete from public.menu_ref where me_code=$1";
00249 $res = $this->cn->exec_sql($sql, array($this->me_code));
00250 }
00251
00252
00253
00254
00255 static function test_me()
00256 {
00257 }
00258
00259 }
00260
00261
00262 ?>