Skip to content

Commit 48e95eb

Browse files
author
Fredrick Peter
committed
Migration Update, Helpers Naming change
1 parent b021618 commit 48e95eb

File tree

15 files changed

+729
-441
lines changed

15 files changed

+729
-441
lines changed

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
104104
**Step 1** — update your `composer.json`:
105105
```composer.json
106106
"require": {
107-
"peterson/php-orm-database": "^3.1.1"
107+
"peterson/php-orm-database": "^3.1.2"
108108
}
109109
```
110110

@@ -1080,8 +1080,6 @@ use builder\Database\Migrations\Migration;
10801080
```
10811081

10821082
### Create Table Schema
1083-
<details><summary>Read more...</summary>
1084-
10851083
- Takes param as `table name`
10861084
- Second parameter `string` `jobs|sessions` (optional) -If passed will create a dummy `jobs|sessions` table schema
10871085

@@ -1098,11 +1096,8 @@ Table `2023_04_19_1681860618_tb_jobs` has been created successfully
10981096
Table `2023_04_19_1681860618_tb_sessions` has been created successfully
10991097
```
11001098
![Sample Session Schema](https://raw.githubusercontent.com/tamedevelopers/UltimateOrmDatabase/main/sessions.png)
1101-
</details>
11021099

11031100
### Run Migration
1104-
<details><summary>Read more...</summary>
1105-
11061101
- You need to pass in `up` as a param
11071102
- This auto create folders/subfolder with read permission
11081103
- The code above execute all files located in [root/database/migrations]
@@ -1114,7 +1109,6 @@ Migration::run('up');
11141109
Migration runned successfully on `2023_04_19_1681860618_user`
11151110
Migration runned successfully on `2023_04_19_1681860618_user_wallet`
11161111
```
1117-
</details>
11181112

11191113
### Drop Table
11201114
<details><summary>Read more...</summary>
@@ -1284,14 +1278,16 @@ class PostClass extends DB{
12841278
| function | Description |
12851279
|---------------------------|-----------------------------------|
12861280
| base_dir() | Return `server` base directory |
1287-
| orm_db() | Return instance of `new DB($options)` class |
1288-
| orm_import() | Return instance of `(new DBImport)` class |
1289-
| orm_migration() | Return instance of `(new Migration)` class |
1290-
| orm_dot_env() | Return instance of `(new OrmDotEnv)` class |
1281+
| db() | Return instance of `new DB($options)` class |
1282+
| db_exec() | Return instance of `(new MySqlExec)` class |
1283+
| import() | Return instance of `(new DBImport)` class |
1284+
| migration() | Return instance of `(new Migration)` class |
1285+
| schema() | Return instance of `(new Schema)` class |
1286+
| dot_env() | Return instance of `(new OrmDotEnv)` class |
12911287
| autoload_env() | Return instance of `(new AutoloadEnv)` class |
12921288
| env_start() | Same as `AutoloadEnv::start()` |
1293-
| config_database() | Same as `Direct DB Connection` get access to `DATABASE_CONNECTION` Constant |
1294-
| configure_pagination() | Same as `$db->configurePagination()` or `AutoloadEnv::configurePagination` |
1289+
| config_database() | Same as `Direct DB Connection` get access to `DATABASE_CONNECTION` Constant |
1290+
| configure_pagination() | Same as `$db->configurePagination()` or `AutoloadEnv::configurePagination` |
12951291
| app_config() | Same as `$db->AppConfig()` |
12961292
| get_connection() | Same as `$db->getConnection()` |
12971293
| get_app_data() | Get `path` `database` & `pagination` info |

src/Collections/Collection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class Collection implements IteratorAggregate, ArrayAccess
3535
* Create a new collection.
3636
*
3737
* @param array $items
38-
*
39-
* @return void
4038
*/
4139
public function __construct($items = [])
4240
{

src/Collections/CollectionMapper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class CollectionMapper implements IteratorAggregate, ArrayAccess
1818
* Create a new collection.
1919
*
2020
* @param mixed $items
21-
* @return void
2221
*/
2322
public function __construct($items = [])
2423
{

src/DB.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
class DB extends Insertion{
1818

19+
/**
20+
* Extending Settings
21+
*
22+
* @param array $options
23+
*/
1924
public function __construct(?array $options = []) {
2025
parent::__construct($options);
2126

src/DBImport.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class DBImport extends DB{
1919
private $realpath;
2020
private $template;
2121
private $array = [];
22-
22+
23+
/**
24+
* Construct Instance of Database
25+
*/
2326
public function __construct() {
2427
parent::__construct();
2528

src/Migrations/Blueprint.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@
1212
use builder\Database\Migrations\Traits\FilePathTrait;
1313
use builder\Database\Migrations\Traits\SchemaCollectionTrait;
1414
use builder\Database\MigrationTrait\Traits\TableStructureTrait;
15+
use builder\Database\Migrations\Traits\SchemaConfigurationTrait;
1516

1617
class Blueprint extends Constants{
1718

1819
use SchemaTrait,
19-
SchemaCollectionTrait,
20+
SchemaCollectionTrait,
21+
SchemaConfigurationTrait,
2022
TableStructureTrait,
2123
FilePathTrait,
2224
ManagerTrait;
2325

2426
/**
2527
* Creating Managers
26-
* @param string $tableName
2728
*
28-
* @return void
29+
* @param string $tableName
2930
*/
3031
public function __construct(?string $tableName = null)
3132
{

src/Migrations/Schema.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Schema extends Constants{
1616
static protected $tableName;
1717
static protected $object;
1818

19-
2019
/**
2120
* Creating Instance of Database
2221
*
@@ -27,6 +26,24 @@ static private function initSchemaDatabase()
2726
self::$db = new DB();
2827
}
2928

29+
/**
30+
* Create a default string length for Database Schema
31+
* @param $length int $length The default length to use for string columns (default: 255)
32+
*
33+
* @return void
34+
*/
35+
static public function defaultStringLength($length = 255)
36+
{
37+
// Check if the provided length is greater than the maximum allowed by MySQL.
38+
if ($length > 15950) {
39+
$length = 15950;
40+
}
41+
42+
if( ! defined('ORM_MAX_STRING_LENGTH') ){
43+
define('ORM_MAX_STRING_LENGTH', $length);
44+
}
45+
}
46+
3047
/**
3148
* Creating Indexs
3249
* @param string $tableName

0 commit comments

Comments
 (0)