[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8128] BIM: tweak primary key on item
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8128] BIM: tweak primary key on item |
Date: |
Fri, 18 Nov 2011 11:47:33 +0000 |
Revision: 8128
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8128
Author: sigurdne
Date: 2011-11-18 11:47:29 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
BIM: tweak primary key on item
Modified Paths:
--------------
trunk/bim/inc/class.sobimitem.inc.php
trunk/bim/setup/tables_current.inc.php
trunk/bim/setup/tables_update.inc.php
trunk/property/inc/class.soentity.inc.php
Modified: trunk/bim/inc/class.sobimitem.inc.php
===================================================================
--- trunk/bim/inc/class.sobimitem.inc.php 2011-11-18 10:22:35 UTC (rev
8127)
+++ trunk/bim/inc/class.sobimitem.inc.php 2011-11-18 11:47:29 UTC (rev
8128)
@@ -77,8 +77,13 @@
throw new Exception('ModelId not set');
}
- $sql = "INSERT INTO ".self::bimItemTable." (type, guid,
xml_representation, model) values (";
- $sql = $sql."(select id from ".self::bimTypeTable." where name
= '".$bimItem->getType()."'),";
+ $this->db->query("SELECT id as type FROM ".self::bimTypeTable."
WHERE name = '".$bimItem->getType()),__LINE__,__FILE__);
+ $this->db->next_record();
+ $type = $this->db->f('type');
+ $id = $this->db->next_id('fm_bim_item',array('type' =>
$type));
+
+ $sql = "INSERT INTO ".self::bimItemTable." (type, id, guid,
xml_representation, model) values ($type, $id,";
+ // $sql = $sql."(select id from ".self::bimTypeTable." where name
= '".$bimItem->getType()."'),";
$sql = $sql."'".$bimItem->getGuid()."',
'".$this->db->db_addslashes($bimItem->getXml())."',
".$bimItem->getModelId().")";
try {
if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
Modified: trunk/bim/setup/tables_current.inc.php
===================================================================
--- trunk/bim/setup/tables_current.inc.php 2011-11-18 10:22:35 UTC (rev
8127)
+++ trunk/bim/setup/tables_current.inc.php 2011-11-18 11:47:29 UTC (rev
8128)
@@ -47,8 +47,8 @@
),
'fm_bim_item' => array(
'fd' => array(
- 'id' => array('type' => 'auto', 'precision' =>
4, 'nullable' => False),
'type' => array('type' => 'int', 'precision' =>
4,'nullable' => False),
+ 'id' => array('type' => 'int', 'precision' =>
4, 'nullable' => False),
'guid' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
'xml_representation' => array('type' =>
'xml','nullable' => False),
'model' => array('type' => 'int', 'precision'
=> 4,'nullable' => False),
@@ -60,7 +60,7 @@
'entry_date' => array('type' =>
'int','precision' => '4','nullable' => True),
'user_id' => array('type' => 'int','precision'
=> '4','nullable' => True),
),
- 'pk' => array('id'),
+ 'pk' => array('type','id'),
'fk' => array('fm_bim_type' => array('type' => 'id')),
// 'fk' => array('fm_bim_model' => array('model' => 'id'),
// 'fm_bim_type' =>
array('type' => 'id')),
Modified: trunk/bim/setup/tables_update.inc.php
===================================================================
--- trunk/bim/setup/tables_update.inc.php 2011-11-18 10:22:35 UTC (rev
8127)
+++ trunk/bim/setup/tables_update.inc.php 2011-11-18 11:47:29 UTC (rev
8128)
@@ -58,9 +58,14 @@
{
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_bim_item','loc1',
array('type' => 'varchar','precision' => '6','nullable' => true));
+ $GLOBALS['phpgw_setup']->oProc->query('ALTER TABLE fm_bim_item
DROP CONSTRAINT fm_bim_item_pkey',__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->oProc->query('ALTER TABLE fm_bim_item
ADD CONSTRAINT fm_bim_item_pkey PRIMARY KEY(type,id)',__LINE__,__FILE__);
if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
{
$GLOBALS['setup_info']['bim']['currentver'] =
'0.9.17.503';
return $GLOBALS['setup_info']['bim']['currentver'];
}
}
+
+
+
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2011-11-18 10:22:35 UTC (rev
8127)
+++ trunk/property/inc/class.soentity.inc.php 2011-11-18 11:47:29 UTC (rev
8128)
@@ -1607,6 +1607,7 @@
$this->db->query("SELECT id as type FROM fm_bim_type
WHERE location_id = {$location_id}",__LINE__,__FILE__);
$this->db->next_record();
$type = $this->db->f('type');
+ $id = $this->db->next_id('fm_bim_item',array('type'
=> $type));
phpgw::import_class('phpgwapi.xmlhelper');
$xmldata = phpgwapi_xmlhelper::toXML($data, 'PHPGW');
@@ -1629,6 +1630,7 @@
$values_insert = array
(
+ 'id' => $id,
'type' =>
$type,
'guid' =>
$guid,
'xml_representation' =>
$this->db->db_addslashes($xml),
@@ -1645,7 +1647,7 @@
$this->db->query("INSERT INTO fm_bim_item (" .
implode(',',array_keys($values_insert)) . ') VALUES ('
.
$this->db->validate_insert(array_values($values_insert)) .
')',__LINE__,__FILE__);
- return
$this->db->get_last_insert_id('fm_bim_item','id');
+ return $id;
}
protected function _edit_eav($data = array(),$location_id, $id)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8128] BIM: tweak primary key on item,
Sigurd Nes <=