-
Notifications
You must be signed in to change notification settings - Fork 0
/
TDBAttributes.php
executable file
·71 lines (47 loc) · 1.25 KB
/
TDBAttributes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once "TDBBase.php";
class TDBAttributes extends TDBEntities
{
static function getEntity($guid)
{
$entityData = parent::getEntity($guid);
$vars = $this->loadvars($entityData['guid']);
$entityData = $entityData + $vars ;
$entity->setData($data);
return $entity;
}
function loadvars($guid)
{
$sql = 'select `name`,`value` from entity_values where guid = '.$guid;
$data = $this->query($sql,true);
$result = array();
foreach($data as $item)
{
$result[$item['name']] = $item['value'];
}
return $result;
}
function updateVars($guid ,$data)
{
unset($data['guid']);
$toupdate = $data;
$fields = $db->Describe($data['entity_type']);
var_dump( $fields );
var_dump( $data );
die;
foreach ($fields as $field)
{
unset($data[$field['Field']]);
}
foreach($data as $key => $item)
{
$sql = 'replace into entities_values (`guid` ,`name` ,`value`) values ("'.$guid.'" , "'.$key.'" , "'.$item.'" )';
$this->update($sql);
}
}
function deleteEntity(&$entity)
{
pullGuid($entity);
$this->update('delete from entities where guid ='.$entity);
}
}