[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r5334 - phpcompta/trunk/include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r5334 - phpcompta/trunk/include |
Date: |
Wed, 10 Jul 2013 21:31:30 +0200 (CEST) |
Author: danydb
Date: 2013-07-10 21:31:30 +0200 (Wed, 10 Jul 2013)
New Revision: 5334
Modified:
phpcompta/trunk/include/class_phpcompta_sql.php
Log:
Documentation
Modified: phpcompta/trunk/include/class_phpcompta_sql.php
===================================================================
--- phpcompta/trunk/include/class_phpcompta_sql.php 2013-07-10 17:16:02 UTC
(rev 5333)
+++ phpcompta/trunk/include/class_phpcompta_sql.php 2013-07-10 19:31:30 UTC
(rev 5334)
@@ -80,22 +80,21 @@
$pk=$this->primary_key;
$this->$pk= $p_id;
- if ($p_id == -1)
- {
/* Initialize an empty object */
foreach ($this->name as $key )
{
$this->$key= null;
}
$this->$pk= $p_id;
- }
- else
- {
/* load it */
$this->load();
- }
}
-
+ public function save() {
+ if ( $this->p_id == -1 )
+ $this->insert();
+ else
+ $this->update();
+ }
public function getp($p_string)
{
if (array_key_exists( $p_string,$this->name))
@@ -212,7 +211,7 @@
$result = $this->cn->get_array($sql);
if ($this->cn->count() == 0 ) {
$this->$pk=-1;
- return;
+ return ;
}
foreach ($result[0] as $key=>$value) {
@@ -232,6 +231,11 @@
}
return 0;
}
+ /**
+ * Transform an array into object
+ * @param type $p_array
+ * @return object
+ */
public function from_array($p_array)
{
foreach ($this->name as $key=>$value)
@@ -247,18 +251,39 @@
}
return $this;
}
+ /**
+ address@hidden retrieve array of object thanks a condition
+ address@hidden $cond condition (where clause) (optional by default all the
rows are fetched)
+ * you can use this parameter for the order or subselect
+ address@hidden $p_array array for the SQL stmt
+ address@hidden Database::exec_sql get_object Database::num_row
+ address@hidden the return value of exec_sql
+ */
function seek($cond='', $p_array=null)
{
$sql = "select * from ".$this->table." $cond";
$ret = $this->cn->exec_sql($sql, $p_array);
return $ret;
}
+ /**
+ *get_seek return the next object, the return of the query must have all
the column
+ * of the object
+ address@hidden $p_ret is the return value of an exec_sql
+ address@hidden $idx is the index
+ address@hidden seek
+ address@hidden object
+ */
public function next($ret,$i) {
$array=$this->cn->fetch_array($ret,$i);
return $this->from_array($array);
}
-
-
+ /**
+ address@hidden next
+ */
+ public function get_object($p_ret,$idx)
+ {
+ return $this->next($p_ret, $i);
+ }
}
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r5334 - phpcompta/trunk/include,
phpcompta-dev <=