Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_copro_parameter.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 /* $Revision$ */
21 
22 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
23 
24 /**
25  * @file
26  * @brief class for the table coprop.parameter
27  *
28  */
30 {
31  // constructor
32  function __construct() {
33  global $cn;
34  $Res=$cn->exec_sql("select * from coprop.parameter ");
35  for ($i = 0;$i < Database::num_row($Res);$i++)
36  {
37  $row=Database::fetch_array($Res,$i);
38  $key=$row['pr_id'];
39  $elt=$row['pr_value'];
40  // store value here
41  $this->{"$key"}=$elt;
42  }
43 
44  }
45  /*!
46  **************************************************
47  * \brief save the parameter into the database by inserting or updating
48  *
49  *
50  * \param $p_attr give the attribut name
51  *
52  */
53  function save($p_option,$p_value)
54  {
55  global $cn;
56  // check if the parameter does exist
57  if ( $cn->get_value('select count(*) from coprop.parameter where pr_id=$1',array($p_option)) != 0 )
58  {
59  $Res=$cn->exec_sql("update coprop.parameter set pr_value=$1 where pr_id=$2",
60  array($p_value,$p_option));
61  }
62  else
63  {
64 
65  $Res=$cn->exec_sql("insert into coprop.parameter (pr_id,pr_value) values( $1,$2)",
66  array($p_option,$p_value));
67 
68  }
69 
70  }
71 
72 }
73 ?>
for($i=0;$i< Database::num_row($ret);$i++) $row
save($p_option, $p_value)
save the parameter into the database by inserting or updating
$key
global $cn