noalyss Version-9
Public Member Functions | Private Attributes
Acc_Plan_SQL Class Reference

this class is above tmp_pcmn_sql and is a view of tmp_pcmn More...

+ Inheritance diagram for Acc_Plan_SQL:
+ Collaboration diagram for Acc_Plan_SQL:

Public Member Functions

 __construct ($p_cn, $p_id=-1)
 
 count ($p_where="", $p_array=null)
 
 delete ()
 
 exist ()
 Count the number of record with the id ,. More...
 
 get_limit_fiche_qcode ()
 
 get_pk_value ()
 
 insert ()
 
 load ()
 Load the current row return false if not found. More...
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition More...
 
 set_limit_fiche_qcode ($limit_fiche_qcode)
 
 update ()
 
- Public Member Functions inherited from Data_SQL
 __construct (DatabaseCore $p_cn, $p_id=-1)
 
 __toString ()
 
 collect_objects ($cond='', $p_array=null)
 return an array of objects. More...
 
 count ($p_where="", $p_array=null)
 
 delete ()
 
 exist ()
 Count the number of record with the id ,. More...
 
 from_array ($p_array)
 Transform an array into object. More...
 
 get ($p_string)
 get the value thanks the colum name and not the alias (name). More...
 
 get_cn ()
 
 get_info ()
 
 get_name ()
 
 get_object ($p_ret, $idx)
 
 get_pk_value ()
 
 get_primary_key ()
 
 get_type ()
 
 getp ($p_string)
 set the value thanks the alias name instead of the colum name More...
 
 insert ()
 
 load ()
 Load the current row return false if not found. More...
 
 next ($ret, $i)
 get_seek return the next object, the return of the query must have all the column of the object More...
 
 save ()
 Insert or update : if the row already exists, update otherwise insert. More...
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition More...
 
 set ($p_string, $p_value)
 set the value thanks the colum name and not the alias (name) More...
 
 set_cn ($cn)
 
 set_name ($name)
 
 set_pk_value ($p_value)
 
 set_primary_key ($primary_key)
 
 set_type ($type)
 
 setp ($p_string, $p_value)
 set the value thanks the alias name instead of the colum name More...
 
 to_array ($prefix="")
 Turn an object (row) into an array, and the key could be prefixed with $prefix. More...
 
 to_row ($p_array)
 turns a row fetched from the DB into a SQL object in updating all his attribute More...
 
 update ()
 
 verify ()
 

Private Attributes

 $limit_fiche_qcode
 

Additional Inherited Members

- Data Fields inherited from Data_SQL
 $cn
 
 $date_format
 Type of the data. More...
 
 $default
 defaullt date format More...
 
 $name
 Database connection. More...
 
 $primary_key
 Array of logical and real name. More...
 
 $table
 
 $type
 Column name of the primary key. More...
 

Detailed Description

this class is above tmp_pcmn_sql and is a view of tmp_pcmn

See also
Tmp_Pcmn_SQL
Acc_Plan_MTable
Examples
ajax_manage_table_sql.php, and test_manage_table_sql.php.

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

Constructor & Destructor Documentation

◆ __construct()

Acc_Plan_SQL::__construct (   $p_cn,
  $p_id = -1 
)

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

37 {
38 $this->table = "accounting_card";
39 $this->primary_key = "id";
40 $this->limit_fiche_qcode=0;
41 $this->name = array(
42 "id" => "id",
43 "pcm_val"=>"pcm_val",
44 "parent_accounting"=>"parent_accounting",
45 "pcm_lib"=>"pcm_lib",
46 "pcm_type"=>"pcm_type",
47 "fiche_qcode"=>"fiche_qcode",
48 "pcm_direct_use"=>"pcm_direct_use"
49 );
50
51 $this->type = array(
52 "id" => "numeric",
53 "pcm_val" => "text",
54 "parent_accounting" => "text",
55 "pcm_lib" => "text",
56 "pcm_type" => "text",
57 "fiche_qcode"=>"string",
58 "pcm_direct_use"=>"text"
59 );
60
61 $this->default = array(
62 "id" => "auto",
63 "fiche_qcode"=>"auto"
64 );
65 $this->sql="
66 SELECT pcm_val,
67 pcm_lib,
68 pcm_val_parent as parent_accounting,
69 pcm_type,
70 id,
71 pcm_direct_use,
72 (select string_agg(m.fiche_qcode,' , ')
73 from (select a.ad_value as fiche_qcode
74 from fiche_detail as a
75 join fiche_detail as b on (a.ad_id=23 and a.f_id=b.f_id and b.ad_id=5)
76 where b.ad_value=pcm_val::text order by a.ad_value %s)as m) as fiche_qcode
77 FROM public.tmp_pcmn
78
79";
80 parent::__construct($p_cn,$p_id);
81 }
$from_poste name
$input_from type
Definition: balance.inc.php:65
$all table

References $p_id, name, table, and type.

Member Function Documentation

◆ count()

Acc_Plan_SQL::count (   $p_where = "",
  $p_array = null 
)

Reimplemented from Data_SQL.

Definition at line 83 of file acc_plan_sql.class.php.

84 {
85 throw new Exception("not implemented");
86 }

◆ delete()

Acc_Plan_SQL::delete ( )

Reimplemented from Data_SQL.

Definition at line 88 of file acc_plan_sql.class.php.

89 {
90 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
91 if ( $this->cn->get_value("select count(*) from jrnx where j_poste=$1",[$obj->pcm_val]) > 0)
92 {
93 throw new Exception(_("Impossible d'effacer : ce poste est utilisé"));
94 }
95 if ( $this->cn->get_value("select count(*) from tmp_pcmn where pcm_val_parent=$1",[$obj->pcm_val]) > 0)
96 {
97 throw new Exception(_("Impossible d'effacer : ce poste est utilisé"));
98 }
99 return $obj->delete();
100
101 }
$input_from cn
Definition: balance.inc.php:66
ORM abstract of the table public.tmp_pcmn.

References $obj, and cn.

◆ exist()

Acc_Plan_SQL::exist ( )

Count the number of record with the id ,.

Returns
integer 0 doesn't exist , 1 exists

Reimplemented from Data_SQL.

Definition at line 103 of file acc_plan_sql.class.php.

104 {
105 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
106 return $obj->exist();
107 }

References $obj, and cn.

◆ get_limit_fiche_qcode()

Acc_Plan_SQL::get_limit_fiche_qcode ( )

Definition at line 172 of file acc_plan_sql.class.php.

173 {
175 }

References $limit_fiche_qcode.

Referenced by load(), and seek().

◆ get_pk_value()

Acc_Plan_SQL::get_pk_value ( )

Reimplemented from Data_SQL.

Definition at line 120 of file acc_plan_sql.class.php.

121 {
122 return $this->id;
123 }

References $id.

◆ insert()

Acc_Plan_SQL::insert ( )

Reimplemented from Data_SQL.

Definition at line 109 of file acc_plan_sql.class.php.

110 {
111 $obj=new Tmp_Pcmn_SQL($this->cn);
112 $obj->set("pcm_val",$this->pcm_val);
113 $obj->set("pcm_lib",$this->pcm_lib);
114 $obj->set("pcm_type",$this->pcm_type);
115 $obj->set("pcm_val_parent",$this->parent_accounting);
116 $obj->set("pcm_direct_use",$this->pcm_direct_use);
117 $obj->insert();
118 $this->id=$obj->id;
119 }

References $obj, and cn.

◆ load()

Acc_Plan_SQL::load ( )

Load the current row return false if not found.

if ( $this->get_limit_fiche_qcode() != 0 )
{
$sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
} else
{
$sql=sprintf($this->sql," ");
}
$result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
if ($this->cn->count()==0)
{
$this->$pk=-1;
return false;
}
foreach ($result[0] as $key=> $value)
{
$this->$key=$value;
}
return true;
$primary_key
Array of logical and real name.
Returns
bool

Reimplemented from Data_SQL.

Definition at line 124 of file acc_plan_sql.class.php.

124 :bool
125 {
127 if ( $this->get_limit_fiche_qcode() != 0 )
128 {
129 $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
130 } else
131 {
132 $sql=sprintf($this->sql," ");
133 }
134 $result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
135 if ($this->cn->count()==0)
136 {
137 $this->$pk=-1;
138 return false;
139 }
140
141 foreach ($result[0] as $key=> $value)
142 {
143 $this->$key=$value;
144 }
145 return true;
146 }

References Data_SQL\$primary_key, $result, $sql, $value, cn, and get_limit_fiche_qcode().

+ Here is the call graph for this function:

◆ seek()

Acc_Plan_SQL::seek (   $cond = '',
  $p_array = null 
)

retrieve array of object thanks a condition

Parameters
$condcondition (where clause) (optional by default all the rows are fetched) you can use this parameter for the order or subselect
$p_arrayarray for the SQL stmt
See also
Database::exec_sql get_object Database::num_row
Returns
the return value of exec_sql

Reimplemented from Data_SQL.

Definition at line 148 of file acc_plan_sql.class.php.

149 {
150 if ( $this->get_limit_fiche_qcode() != 0 )
151 {
152 $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
153 } else
154 {
155 $sql=sprintf($this->sql," ");
156 }
157 $ret=$this->cn->exec_sql($sql." ".$cond,$p_array);
158 return $ret;
159 }

References $p_array, $ret, $sql, cn, and get_limit_fiche_qcode().

+ Here is the call graph for this function:

◆ set_limit_fiche_qcode()

Acc_Plan_SQL::set_limit_fiche_qcode (   $limit_fiche_qcode)

Definition at line 177 of file acc_plan_sql.class.php.

178 {
179 $this->limit_fiche_qcode=$limit_fiche_qcode;
180 }

References $limit_fiche_qcode.

◆ update()

Acc_Plan_SQL::update ( )

Reimplemented from Data_SQL.

Definition at line 161 of file acc_plan_sql.class.php.

162 {
163 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
164 $obj->set("pcm_val",$this->pcm_val);
165 $obj->set("pcm_lib",$this->pcm_lib);
166 $obj->set("pcm_type",$this->pcm_type);
167 $obj->set("pcm_val_parent",$this->parent_accounting);
168 $obj->set("pcm_direct_use",$this->pcm_direct_use);
169
170 $obj->update();
171 }

References $obj, and cn.

Field Documentation

◆ $limit_fiche_qcode

Acc_Plan_SQL::$limit_fiche_qcode
private

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

Referenced by get_limit_fiche_qcode(), and set_limit_fiche_qcode().


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