Skip to content

Commit 27dc425

Browse files
committed
So let's go to the world
1 parent 28f2f1b commit 27dc425

File tree

456 files changed

+516
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

456 files changed

+516
-500
lines changed

Examples/addressbook.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Dotenv\Dotenv;
6+
7+
define('EASE_LOGGER', 'syslog|console');
8+
9+
require_once dirname(__DIR__).'/vendor/autoload.php';
10+
11+
$dotenv = Dotenv::createImmutable(dirname(__DIR__));
12+
$dotenv->load();
13+
14+
$address = new \SpojeNet\PohodaSQL\Adresar();
15+
16+
$address->dbsync(['ID' => 1, 'Obec' => 'Praha']);
17+
18+
print_r($address->getData());

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
PohodaSQL
22
=========
3+
4+
PHP Librabry for direct access to Pohoda SQL database tables
5+
6+
Use at your own risk!
7+
8+
Configuration
9+
-------------
10+
11+
Please set up this constants or environment variables:
12+
13+
* DB_TYPE We use sqlsrv
14+
* DB_HOST IP or Hostname machine with SQL Server
15+
* DB_PORT default is 1433
16+
* DB_DATABASE something like StwPh_01234567_2019
17+
* DB_USERNAME sqlserver login
18+
* DB_PASSWORD sqlserver pass
19+
20+
You can also int object like this:
21+
22+
```php
23+
$addr = new Adresar(234,['database'=>'StwPh_01234567_2020']); //Load record by ID from overriden Database
24+
$addr = new Adresar(['ICO'=>'69438676']); //Load record by ICO
25+
```
26+
27+
See https://github.com/VitexSoftware/php-ease-fluentpdo for mor informations

src/SpojeNet/PohodaSQL/Adresar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Adresar extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/Agenda.php

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/SpojeNet/PohodaSQL/CiselnaRada.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SCRady extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/Faktura.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Faktura extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/FakturaPolozka.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FakturaPolozka extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/Majetek.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Majetek extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/MajetkoveOperace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MajetkoveOperace extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

src/SpojeNet/PohodaSQL/OdpisovyPlan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class OdpisovyPlan extends Agenda
2525
* SQL Table structure
2626
* @const array
2727
*/
28-
const STRUCTURE = [
28+
public $struct = [
2929
'ID' =>
3030
[
3131
'type' => 'int',

0 commit comments

Comments
 (0)