[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10185] Logistic: Changed add method
From: |
Torstein |
Subject: |
[Fmsystem-commits] [10185] Logistic: Changed add method |
Date: |
Wed, 10 Oct 2012 06:52:50 +0000 |
Revision: 10185
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10185
Author: vator
Date: 2012-10-10 06:52:48 +0000 (Wed, 10 Oct 2012)
Log Message:
-----------
Logistic: Changed add method
Modified Paths:
--------------
trunk/logistic/inc/class.sorequirement.inc.php
Modified: trunk/logistic/inc/class.sorequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement.inc.php 2012-10-09 12:42:04 UTC
(rev 10184)
+++ trunk/logistic/inc/class.sorequirement.inc.php 2012-10-10 06:52:48 UTC
(rev 10185)
@@ -35,11 +35,65 @@
{
protected static $so;
- protected function add(&$object)
+ protected function add(&$requirement)
{
+ $cols = array(
+ 'activity_id',
+ 'date_from',
+ 'date_to',
+ 'no_of_elements',
+ 'location_id',
+ 'create_user',
+ 'create_date'
+ );
+ $values = array(
+ $this->marshal($requirement->get_activity_id(),
'int'),
+ $this->marshal($requirement->get_date_from(),
'string'),
+ $this->marshal($requirement->get_date_to(),
'string'),
+
$this->marshal($requirement->get_no_of_elements(), 'int'),
+ $this->marshal($requirement->get_location_id(),
'int'),
+ $this->marshal($requirement->get_create_user(),
'int'),
+ $this->marshal(strtotime('now'), 'int')
+ );
+
+ $sql = 'INSERT INTO lg_requirement (' . join(',',
$cols) . ') VALUES (' . join(',', $values) . ')';
+ $result = $this->db->query($sql, __LINE__,__FILE__);
+
+ if($result)
+ {
+ return
$this->db->get_last_insert_id('lg_requirement', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
+ protected function update($requirement)
+ {
+ $id = intval($requirement->get_id());
+
+ $values = array(
+ 'activity_id=' .
$this->marshal($requirement->get_activity_id(), 'int'),
+ 'date_from=' .
$this->marshal($requirement->get_date_from(), 'int'),
+ 'date_to=' .
$this->marshal($requirement->get_date_to(), 'int'),
+ 'no_of_elements=' .
$this->marshal($requirement->get_no_of_elements(), 'int'),
+ 'location_id=' .
$this->marshal($requirement->get_location_id(), 'int')
+ );
+
+ $result = $this->db->query('UPDATE lg_requirement SET '
. join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
+
+ if($result)
+ {
+ return $id;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
protected function get_id_field_name()
{
if(!$extended_info)
@@ -131,11 +185,6 @@
return $requirement;
}
- protected function update($object)
- {
-
- }
-
public static function get_instance()
{
if (self::$so == null)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10185] Logistic: Changed add method,
Torstein <=