- Installation
- Core Concepts
- Addons
- App Model
- Databases method
- Tables method
- Columns method
- Data methods
olive-cms/udms is available on Packagist (olive-cms/udms) and as such installable via Composer.
composer require olive-cms/udms
If you do not use Composer, you can grab the code from GitHub, and use any PSR-0 compatible autoloader (e.g. the Symfony2 ClassLoader component) to load Monolog classes.
Coming soon!
// load autoload
require_once '/path/to/vendor/autoload.php';
use Olive\UDMS\Core as udms;
// create a udms
$udms = new udms('/path/to/vendor/', '/path/to/database/dir');
$list = $udms->getAddonsList();
/* output array
* example:
Array
(
[0] => MySQL
[1] => MongoDB
[2] => Json
)
*/
Set you Selection addon
// output void
$udms->setAddon('json');
$udms->setAppModel(
[
'school' // database name
=> [
'student' // table name
=> [
'id' // column name
=> [
'type' => 'int',
'index' => 'primary',
'auto' => [
'start' => 93000000,
'add' => 43
]
],
'fullname' => [
'type' => 'text',
'__udms_config'
=> [
'mysql_mysql' => [
'charset' => [
'utf8' => 'utf8_persian_ci'
]
]
]
]
]
]
]
);
// output void
Render App model for Your selection addon:
/*
* important: first set addon and next render!
* output void
*/
$udms->render();
Some addons (example mysql) with some config, Does not allow for Create Database. this method for test available create database.
// output Boolean
if($udms->availableDatabaseRule()) {
// available
} else {
// not available
}
// output void
$udms->createDatabase('school',
[] // config
);
Check exists Database
// output Boolean
if($udms->existsDatabase('school')) {
// exists
} else {
// not exists
}
/*
* Warning: delete databse dir in udms chache dir
* output void
*/
$udms->dropDatabase('school');
// output void
$udms->renameDatabase('school', 'to');
$list = $udms->listDatabases();
/* output array
* example:
Array
(
[0] => school
)
*/
Check available table rule
// output Boolean
if($udms->school->availableTableRule()) {
// available
} else {
// not available
}
// output void
$udms->school->createTable('studnet',
[] // config
);
Check exist table
// output Boolean
if($udms->school->existsTable('studnet')) {
// exists
} else {
// not exists
}
// output void
$udms->school->dropTable('studnet');
/*
* Notice: rename database dir in udms cache dir
* output void
*/
$udms->school->renameTable('studnet', 'to');
// output void
$udms->school->cleanTable('studnet');
$list = $udms->school->listTables();
/* output array
* example:
Array
(
[0] => class
[1] => students
[2] => teacher
)
*/
Check available columns rule
// output Boolean
if($udms->school->availableColumnRule()) {
// available
} else {
// not available
}
// output void
$udms->school->student->createColumn('studnet',
[] // config
);
/**
* config available:
* @param type -> [int, text]
* @param length -> (0==ultimate)
* @param index -> [primary]
* @param auto -> [start => int, add => int]
* @param __udms_rel -> [table => column]
*/
/*
# example 1:
$udms->school->classes->createColumn('id',
[
'type' => 'int',
'lenght' => 8,
'index' => 'primary',
'auto' => [
'start' => 1000000,
'add' => 367
]
]
);
# example 2:
$udms->school->classes->createColumn('t_id',
[
'__udms_rel' => [
'teacher' => 'id'
]
]
);
*/
Check exists column
// output Boolean
if($udms->school->student->existsColumn('studnet')) {
// exists
} else {
// not exists
}
// output void
$udms->school->student->dropColumn('studnet');
$list = $udms->school->student->listColumns();
/* output array
* example:
Array
(
[0] => id
[1] => first_name
[2] => last_name
)
*/
$uid = $udms->school->student->insert(
[
'fname' => 'mehdi',
'lname' => 'hosseinzade'
]
);
/* output String
* string "c4ca4238a0b923820dcc509a6f75849b"
*/
// output void
$udms->school->student->update($uid,
[
'fname' => 'arshen'
]
);
// output void
$udms->school->student->delete($uid);
$list_1 = $udms->school->student->find(
[
'id' => [
'<' => 9400000,
'>' => 9200000
],
'lname' => [
'match' => '/(zade)+/'
]
],
// options
[
'relation' => false,
'sort' => [
'name' => SORT_DESC
]
]
);
/* output array
* example
Array
(
[0] => Array
(
[fname] => mehdi
[lname] => hosseinzade
[id] => 93000000
[__udms_id] => 529d1ff34a86af52e136858a8e7efc40
)
)
*/
alias find method without filter
$list_1 = $udms->school->student->get(
[
'relation' => false,
'sort' => [
'lname' => SORT_ASC
],
'limit' => 5
]
);
/* output array
* example:
Array
(
[0] => Array
(
[fname] => alireza
[lname] => aghaeipour
[id] => 93000172
[__udms_id] => 92277596d3fe0baaf6814caaa2f9fb17
)
[1] => Array
(
[fname] => mehdi
[lname] => hosseinzade
[id] => 93000000
[__udms_id] => 529d1ff34a86af52e136858a8e7efc40
)
[2] => Array
(
[fname] => abolfazl
[lname] => nazerpanah
[id] => 93000129
[__udms_id] => 390aa37bf6aabfa8af16bb729f02d207
)
[3] => Array
(
[fname] => mehrzad
[lname] => poureghbal
[id] => 93000043
[__udms_id] => 64df99136dc56fc4ba306a1fffe75231
)
[4] => Array
(
[fname] => mohammad
[lname] => rezaei
[id] => 93000086
[__udms_id] => 1fa3d2ab103b82e368c534f87720f8e2
)
)
*/