@@ -22,23 +22,27 @@ class Agenda extends \Ease\SQL\Engine
2222 public $ keyColumn = 'ID ' ; //sloupeček pro defaultní klíčování
2323
2424 /**
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)
2935 */
30- public function __construct ( $ identifier = null , $ options = [])
36+ public function setUp ( $ options = [])
3137 {
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 );
4246 }
4347
4448 /**
@@ -51,7 +55,7 @@ public function __construct($identifier = null, $options = [])
5155 */
5256 public function setDataValue ($ columnName , $ value )
5357 {
54- return array_key_exists ($ columnName , self :: STRUCTURE ) ? parent ::setDataValue ($ columnName ,
58+ return array_key_exists ($ columnName , $ this -> struct ) ? parent ::setDataValue ($ columnName ,
5559 $ value ) : new Exception ('Unknown field ' .$ columnName );
5660 }
5761
@@ -74,35 +78,4 @@ public function getIDS()
7478 {
7579 return $ this ->getDataValue ('IDS ' );
7680 }
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- }
10881}
0 commit comments