@@ -22,23 +22,27 @@ class Agenda extends \Ease\SQL\Engine
22
22
public $ keyColumn = 'ID ' ; //sloupeček pro defaultní klíčování
23
23
24
24
/**
25
- * Database object
26
- *
27
- * @param mixed $identifier
28
- * @param array $options
25
+ * SQL Table structure
26
+ * @const array
27
+ */
28
+ public $ struct = [];
29
+
30
+ /**
31
+ * SetUp Object to be ready for connect
32
+ *
33
+ * @param array $options Object Options (dbType,server,username,password,database,
34
+ * port,connectionSettings,myTable,debug)
29
35
*/
30
- public function __construct ( $ identifier = null , $ options = [])
36
+ public function setUp ( $ options = [])
31
37
{
32
- if (defined (self ::STRUCTURE )) {
33
- $ this ->setMyKey (array_key_exists ('ID ' , self ::STRUCTURE ) ? 'ID ' : null );
34
- $ this ->myCreatedColumn = array_key_exists ('DatCreate ' ,
35
- self ::STRUCTURE ) ? 'DatCreate ' : null ;
36
- $ this ->myLastModifiedColumn = array_key_exists ('DatSave ' ,
37
- self ::STRUCTURE ) ? 'DatSave ' : null ;
38
- $ this ->nameColumn = array_key_exists ('IDS ' ,
39
- self ::STRUCTURE ) ? 'IDS ' : null ;
40
- }
41
- parent ::__construct ($ identifier , $ options );
38
+ $ this ->setKeyColumn (array_key_exists ('ID ' , $ this ->struct ) ? 'ID ' : null );
39
+ $ this ->createdColumn = array_key_exists ('DatCreate ' , $ this ->struct )
40
+ ? 'DatCreate ' : null ;
41
+ $ this ->lastModifiedColumn = array_key_exists ('DatSave ' , $ this ->struct ) ? 'DatSave '
42
+ : null ;
43
+ $ this ->nameColumn = array_key_exists ('IDS ' , $ this ->struct ) ? 'IDS '
44
+ : null ;
45
+ parent ::setUp ($ options );
42
46
}
43
47
44
48
/**
@@ -51,7 +55,7 @@ public function __construct($identifier = null, $options = [])
51
55
*/
52
56
public function setDataValue ($ columnName , $ value )
53
57
{
54
- return array_key_exists ($ columnName , self :: STRUCTURE ) ? parent ::setDataValue ($ columnName ,
58
+ return array_key_exists ($ columnName , $ this -> struct ) ? parent ::setDataValue ($ columnName ,
55
59
$ value ) : new Exception ('Unknown field ' .$ columnName );
56
60
}
57
61
@@ -74,35 +78,4 @@ public function getIDS()
74
78
{
75
79
return $ this ->getDataValue ('IDS ' );
76
80
}
77
-
78
- /**
79
- * Load Pohoda Data
80
- *
81
- * @param int|string $itemId use string to load by IDS (integer for ID)
82
- *
83
- * @return int number of columns loaded
84
- */
85
- public function loadFromSQL ($ itemId )
86
- {
87
- $ bck = $ this ->getKeyColumn ();
88
- if (is_string ($ itemId )) {
89
- $ this ->setKeyColumn ('IDS ' );
90
- }
91
- $ loaded = parent ::loadFromSQL ($ itemId );
92
- $ this ->setKeyColumn ($ bck );
93
- return $ loaded ;
94
- }
95
-
96
- /**
97
- * Synchronise object data with database
98
- *
99
- * @param array $data
100
- *
101
- * @return boolean
102
- */
103
- public function sync ($ data = null )
104
- {
105
- return $ this ->loadFromSQL ($ this ->insertToSQL (is_null ($ data ) ? $ this ->getData ()
106
- : $ data )) == 1 ;
107
- }
108
81
}
0 commit comments