aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-04-24 17:05:36 +0200
committerWilly Micieli <micieli@laposte.net>2019-04-24 17:05:36 +0200
commit230c03caaeb97f2af89475f5a7976267d3e3f221 (patch)
tree55374de07aab5c070ba5eb3fd982c6633cdfdd84
parent8ce60e51849aac48e738bbedbdb9a0bbd3f762f5 (diff)
downloadimperium-230c03caaeb97f2af89475f5a7976267d3e3f221.zip
imperium-230c03caaeb97f2af89475f5a7976267d3e3f221.tar.gz
fix bugs support sqlite completemently8.2
-rw-r--r--Makefile3
-rw-r--r--README.md2
-rw-r--r--db/migrations/20190424135413_users.php33
-rw-r--r--db/seeds/UsersSeed.php20
-rw-r--r--helpers/helpers.php147
-rw-r--r--imperium/Bases/Base.php2
-rw-r--r--imperium/Command/App.php23
-rw-r--r--imperium/Command/Command.php6
-rw-r--r--imperium/Command/DumpDatabase.php2
-rw-r--r--imperium/Command/FindRoute.php12
-rw-r--r--imperium/Command/GenerateMigrations.php5
-rw-r--r--imperium/Command/MaintenanceMode.php29
-rw-r--r--imperium/Command/MigrateDatabase.php2
-rw-r--r--imperium/Command/RollbackDatabase.php1
-rw-r--r--imperium/Command/RoutesList.php2
-rw-r--r--imperium/Command/RunMode.php29
-rw-r--r--imperium/Command/SeedDatabase.php1
-rw-r--r--imperium/Command/Server.php1
-rw-r--r--imperium/Command/UpdateDatabase.php2
-rw-r--r--imperium/Connexion/Connect.php38
-rw-r--r--imperium/Dump/Dump.php2
-rw-r--r--imperium/Import/Import.php7
-rw-r--r--imperium/Model/Model.php2
-rw-r--r--mysql.yaml2
-rw-r--r--pgsql.yaml2
-rw-r--r--phinx.php17
-rw-r--r--sqlite.yaml2
-rw-r--r--tests/mysql/app/AppTest.php8
-rw-r--r--tests/mysql/base/BaseTest.php11
29 files changed, 268 insertions, 145 deletions
diff --git a/Makefile b/Makefile
index 9614a50..ebd3294 100644
--- a/Makefile
+++ b/Makefile
@@ -29,8 +29,9 @@ endif
all: vendor mysql pgsql sqlite router form dir config session flash app trans csrf hash collection
-mysql: seed
+mysql:
@install -D $@.yaml config/db.yaml
+ @php shaolin db:seed
@$(UNIT) tests/$@ $(COVERAGE) coverage/$@
pgsql: seed
@install -D $@.yaml config/db.yaml
diff --git a/README.md b/README.md
index 0e8cf3e..e35f2b0 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@
* [**Helpers**](https://git.fumseck.eu/cgit/imperium/tree/app/helpers.php)
* [**Discord**](https://discord.gg/fUPyd9K)
* [**Trello**](https://trello.com/b/28tMSSDG/imperium)
-* [**Diff**](https://git.fumseck.eu/cgit/imperium/diff/?id=8.1.7&id2=8.1.6&dt=2)
+* [**Diff**](https://git.fumseck.eu/cgit/imperium/diff/?id=8.2&id2=8.1.7&dt=2)
# What it's ?
diff --git a/db/migrations/20190424135413_users.php b/db/migrations/20190424135413_users.php
new file mode 100644
index 0000000..832dbd8
--- /dev/null
+++ b/db/migrations/20190424135413_users.php
@@ -0,0 +1,33 @@
+<?php
+
+
+use Phinx\Migration\AbstractMigration;
+
+class Users extends AbstractMigration
+{
+ /**
+ * Change Method.
+ *
+ * Write your reversible migrations using this method.
+ *
+ * More information on writing migrations is available here:
+ * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+ *
+ * The following commands can be used in this method and Phinx will
+ * automatically reverse them when rolling back:
+ *
+ * createTable
+ * renameTable
+ * addColumn
+ * renameColumn
+ * addIndex
+ * addForeignKey
+ *
+ * Remember to call "create()" or "update()" and NOT "save()" when working
+ * with the Table class.
+ */
+ public function change()
+ {
+
+ }
+}
diff --git a/db/seeds/UsersSeed.php b/db/seeds/UsersSeed.php
new file mode 100644
index 0000000..b198011
--- /dev/null
+++ b/db/seeds/UsersSeed.php
@@ -0,0 +1,20 @@
+<?php
+
+
+use Phinx\Seed\AbstractSeed;
+
+class UsersSeed extends AbstractSeed
+{
+ /**
+ * Run Method.
+ *
+ * Write your database seeder using this method.
+ *
+ * More information on writing seeders is available here:
+ * http://docs.phinx.org/en/latest/seeding.html
+ */
+ public function run()
+ {
+ $this->table('users')->create();
+ }
+}
diff --git a/helpers/helpers.php b/helpers/helpers.php
index 99262c6..642622a 100644
--- a/helpers/helpers.php
+++ b/helpers/helpers.php
@@ -335,7 +335,7 @@ if (not_exist('register_page'))
<input type="hidden" name="created_at" value="'.now()->format('Y-m-d').'">
<input type="hidden" name="updated_at" value="'.now()->format('Y-m-d').'">
<div class="form-label-group">
- <input type="text" id="username" name="username" class="form-control" placeholder="'.$username_text.'" required>
+ <input type="text" id="username" name="username" class="form-control" placeholder="'.$username_text.'" required autofocus="autofocus ">
<label for="username">'.$username_text.'</label>
</div>
<div class="form-label-group">
@@ -588,24 +588,29 @@ if (not_exist('view'))
*/
function view(string $class,string $name,array $args =[]) : string
{
-
- $dir = str_replace('Controller','',collection(explode("\\",$class))->last());
+ if (def($class))
+ {
+ $dir = str_replace('Controller','',collection(explode("\\",$class))->last());
- if (strstr($name,'@'))
- {
- $file = collection(explode('/',$name));
- $file = collection(explode('.',$file->last()))->begin();
- append($file,'.twig');
- }
- else
- {
- $file = collection(explode('.',$name))->begin();
- append($file,'.twig');
- }
+ if (strstr($name,'@'))
+ {
+ $file = collection(explode('/',$name));
+ $file = collection(explode('.',$file->last()))->begin();
+ append($file,'.twig');
+ }
+ else
+ {
+ $file = collection(explode('.',$name))->begin();
+ append($file,'.twig');
+ }
- $file = $dir .DIRECTORY_SEPARATOR . $file;
+ $file = $dir .DIRECTORY_SEPARATOR . $file;
+ return (new View())->load($file,$args);
+ }
+ $file = collection(explode('.',$name))->begin();
+ append($file,'.twig');
return (new View())->load($file,$args);
}
}
@@ -737,7 +742,10 @@ if (not_exist('sql_file'))
*/
function sql_file(string $table = ''): string
{
- return def($table) ? app()->connect()->dump_path() .DIRECTORY_SEPARATOR ."$table.sql" : app()->connect()->dump_path() . DIRECTORY_SEPARATOR . app()->connect()->base() .'.sql';
+ if (def($table) && different(\app()->connect()->driver(),SQLITE))
+ return def($table) ? app()->connect()->dump_path() .DIRECTORY_SEPARATOR ."$table.sql" : app()->connect()->dump_path() . DIRECTORY_SEPARATOR . app()->connect()->base() .'.sql';
+ else
+ return \app()->connect()->dump_path() .DIRECTORY_SEPARATOR . \collection(explode('.',collection(explode(DIRECTORY_SEPARATOR,app()->connect()->base()))->last()))->begin() .'.sql';
}
}
@@ -1226,7 +1234,7 @@ if (not_exist('edit'))
if(not_exist('navbar'))
{
- function navbar(string $app_name,string $classes,array $routes)
+ function navbar(string $app_name,string $classes,array $routes =[])
{
$html = '<nav class="'.$classes.'">
<div class="container-fluid">
@@ -1234,11 +1242,15 @@ if(not_exist('navbar'))
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
+
+
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">';
- foreach ($routes as $route)
- $html.='<li class="nav-item"><a class="nav-link" href="'.route($route).'">'.strtoupper(route_name($route)).'</a></li>';
-
+ if (def($routes))
+ {
+ foreach ($routes as $route)
+ $html.='<li class="nav-item"><a class="nav-link" href="'.route($route).'">'.strtoupper(route_name($route)).'</a></li>';
+ }
$file = collection(config('navigation','routes'));
if (app()->auth()->connected())
@@ -2040,63 +2052,72 @@ if(not_exist('routes'))
*/
function routes(OutputInterface $output,array $routes): void
{
- if (app()->table_exist(Router::ROUTES))
- {
- if (def($routes))
+
+
+ if (app()->table_exist(Router::ROUTES))
+ {
+ if (def($routes))
+ {
+ $output->write("+-------+-------------------------------+---------------------------------------+-------------------------------+-----------------------+\n");
+
+ foreach ($routes as $route)
{
- $output->write("+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------------+\n");
- $output->write("|\tMETHOD\t\t|\tNAME\t\t\t|\tURL\t\t\t|\tCONTROLLER\t\t|\tACTION\t\t|\n");
- $output->write("+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------------+\n");
- foreach ($routes as $route)
- {
- $name = $route->name;
- $url = $route->url;
- $controller = $route->controller;
- $action = $route->action;
- $method = $route->method;
-
- $output->write("|\t$method\t\t");
-
- if (length($name) < 8)
- $output->write("|\t$name\t\t\t|");
- elseif(length($name) > 15)
- $output->write("|\t$name\t|");
- else
- $output->write("|\t$name\t\t|");
+ $name = "<fg=blue;options=bold>$route->name</>";
+ $url = "<fg=magenta;options=bold>$route->url</>";
+ $controller = "<fg=green;options=bold>$route->controller</>";
+ $action = "<fg=yellow;options=bold>$route->action</>";
+ $method = "<fg=cyan;options=bold>$route->method</>";
- if (length($url) < 8)
- $output->write("\t$url\t\t\t|");
- elseif(length($name) > 15)
- $output->write("\t$url\t|");
- else
- $output->write("\t$url\t\t|");
+ $output->write("| $method\t");
+ if (length($route->name) < 5)
+ $output->write("| $name\t\t\t\t|");
+
+ elseif(length($route->name) > 10)
+ $output->write("| $name\t\t|");
+ else
+ $output->write("| $name\t\t\t|");
- if (length($controller) < 8)
- $output->write("\t$controller\t\t\t|");
- else if(length($controller)> 15)
- $output->write("\t$controller\t|");
- else
- $output->write("\t$controller\t\t|");
- if (length($action) < 8)
- $output->write("\t$action\t\t|\n");
+ if (length($route->url) < 5)
+ $output->write(" $url\t\t\t\t\t|");
+ elseif(length($route->url) < 12)
+ $output->write(" $url\t\t\t\t|");
+ elseif(length($route->url)> 18 )
+ $output->write(" $url\t\t|");
else
- $output->write("\t$action\t|\n");
+ $output->write(" $url\t\t\t|");
+
+
- $output->write("+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------------+\n"); }
- }else{
- $output->write("<error>No routes was found</error>\n");
+ if (length($route->controller) < 8)
+ $output->write(" $controller\t\t\t|");
+ elseif (length($route->controller) > 8 && length($route->controller) < 15)
+ $output->write(" $controller\t\t|");
+ else if(length($route->controller)> 15)
+ $output->write(" $controller\t\t|");
+ else
+ $output->write(" $controller\t\t|");
+
+ if (length($route->action) < 8)
+ $output->write(" $action\t\t\t|\n");
+ else
+ $output->write(" $action\t\t|\n");
+ $output->write("+-------+-------------------------------+---------------------------------------+-------------------------------+-----------------------+\n");
}
+ }else{
+ $output->write("<error>No routes was found</error>\n");
+ }
- }else{
- $output->write("<error>The routes table was not fond</error>\n");
- }
+ }else{
+ $output->write("<error>The routes table was not fond</error>\n");
}
}
+}
+
if (not_exist('simply_view'))
{
diff --git a/imperium/Bases/Base.php b/imperium/Bases/Base.php
index 2b45ff5..9deeaa2 100644
--- a/imperium/Bases/Base.php
+++ b/imperium/Bases/Base.php
@@ -586,7 +586,7 @@ use Imperium\Tables\Table;
if (not_def($this->charset))
throw new Exception("We have not found required charset");
- return equal(Connect::MYSQL,$this->driver) ? $this->connexion->execute("ALTER DATABASE $base CHARACTER SET = {$this->charset}") : $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('{$this->charset}') where datname = '$base'");
+ return equal(MYSQL,$this->driver) ? $this->connexion->execute("ALTER DATABASE $base CHARACTER SET $this->charset;") : $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('{$this->charset}') where datname = '$base'");
}
/**
diff --git a/imperium/Command/App.php b/imperium/Command/App.php
index d1a869a..62f2393 100644
--- a/imperium/Command/App.php
+++ b/imperium/Command/App.php
@@ -26,7 +26,7 @@ namespace Imperium\Command {
protected function configure()
{
- $this->setDescription("Create the application structure");
+ $this->setDescription("Create the application structure")->setAliases(['create']);
}
public function interact(InputInterface $input, OutputInterface $output)
@@ -89,12 +89,13 @@ namespace Imperium\Command {
File::remove_if_exist('phinx.php');
File::create('phinx.php');
File::put('phinx.php',"<?php
-
-\$file = 'db';
+
+\$x = app()->connect();
+
return [
\"paths\" => [
- \"migrations\" => \"{$this->database_dir}/migrations\",
- \"seeds\" => \"{$this->database_dir}/seeds\"
+ \"migrations\" => \"$this->database_dir/migrations\",
+ \"seeds\" => \"$this->database_dir/seeds\"
],
\"environments\" =>
[
@@ -102,12 +103,12 @@ return [
'default_database' => 'development',
'development' =>
[
- \"adapter\" => config(\$file,'driver'),
- \"host\" => config(\$file,'host'),
- \"name\" => config(\$file,'base'),
- \"user\" => config(\$file,'username'),
- \"pass\" => config(\$file,'password'),
- \"port\" => config(\$file,'port'),
+ \"adapter\" => \$x->driver(),
+ \"host\" => \$x->host(),
+ \"name\" => \$x->base(),
+ \"user\" => \$x->user(),
+ \"pass\" => \$x->password(),
+ \"port\" => config('db','port'),
]
]
];");
diff --git a/imperium/Command/Command.php b/imperium/Command/Command.php
index 046a746..44eb712 100644
--- a/imperium/Command/Command.php
+++ b/imperium/Command/Command.php
@@ -22,7 +22,7 @@ namespace Imperium\Command {
*/
public function __construct(string $name = "UNKNOWN", string $version = 'UNKNOWN')
{
- clear_terminal();
+ clear_terminal();
$this->command = new Application($name,$version);
@@ -59,7 +59,9 @@ namespace Imperium\Command {
new DumpDatabase(),
new UpdateDatabase(),
new GenerateMigrations(),
- new FindRoute()
+ new FindRoute(),
+ new MaintenanceMode(),
+ new RunMode()
diff --git a/imperium/Command/DumpDatabase.php b/imperium/Command/DumpDatabase.php
index 105f381..02ba84e 100644
--- a/imperium/Command/DumpDatabase.php
+++ b/imperium/Command/DumpDatabase.php
@@ -14,7 +14,7 @@ namespace Imperium\Command {
{
$base = config('db','base');
-
+ $this->setAliases(['dump']);
$this->setDescription("Dump the $base database");
}
diff --git a/imperium/Command/FindRoute.php b/imperium/Command/FindRoute.php
index 37e789c..5e9008d 100644
--- a/imperium/Command/FindRoute.php
+++ b/imperium/Command/FindRoute.php
@@ -13,9 +13,9 @@ namespace Imperium\Command {
class FindRoute extends Command
{
- protected static $defaultName = 'routes:find';
+ protected static $defaultName = 'routes:search';
- private $name;
+ private $search;
private function clean()
{
@@ -43,12 +43,12 @@ namespace Imperium\Command {
do {
$this->clean();
- $question = new Question("<info>Please enter the route name : </info>");
+ $question = new Question("<info>Please enter the search value : </info>");
- $this->name = $helper->ask($input, $output, $question);
- }while (is_null($this->name));
+ $this->search = $helper->ask($input, $output, $question);
+ }while (is_null($this->search));
- $routes = app()->model()->from(Router::ROUTES)->search($this->name);
+ $routes = app()->model()->from(Router::ROUTES)->search($this->search);
routes($output,$routes);
$question = new Question("<info>Continue searching ? [Y/n] : </info>",'Y');
diff --git a/imperium/Command/GenerateMigrations.php b/imperium/Command/GenerateMigrations.php
index e59348f..097b841 100644
--- a/imperium/Command/GenerateMigrations.php
+++ b/imperium/Command/GenerateMigrations.php
@@ -27,9 +27,8 @@ namespace Imperium\Command {
$name = $input->getArgument('name');
$seed = $name .'Seed';
- shell_exec("vendor/bin/phinx create $name");
- shell_exec("vendor/bin/phinx seed:create $seed");
- return 0;
+ return shell_exec("vendor/bin/phinx create $name") && shell_exec("vendor/bin/phinx seed:create $seed");
+
}
}
diff --git a/imperium/Command/MaintenanceMode.php b/imperium/Command/MaintenanceMode.php
new file mode 100644
index 0000000..ac2a059
--- /dev/null
+++ b/imperium/Command/MaintenanceMode.php
@@ -0,0 +1,29 @@
+<?php
+
+
+namespace Imperium\Command {
+
+
+ use Imperium\File\File;
+ use Symfony\Component\Console\Command\Command;
+ use Symfony\Component\Console\Input\InputInterface;
+ use Symfony\Component\Console\Output\OutputInterface;
+
+ class MaintenanceMode extends Command
+ {
+ protected static $defaultName = 'app:down';
+
+
+ protected function configure()
+ {
+ $this->setDescription('Turn the application in the maintenance mode')->setAliases(['down']);
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ return File::put("web/index.php","<?php\n\n\trequire_once dirname(__DIR__) . '/vendor/autoload.php';\n\n\techo view('','maintenance/maintenance');") === true;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Command/MigrateDatabase.php b/imperium/Command/MigrateDatabase.php
index ea7882a..c1104ff 100644
--- a/imperium/Command/MigrateDatabase.php
+++ b/imperium/Command/MigrateDatabase.php
@@ -12,7 +12,7 @@ namespace Imperium\Command {
protected static $defaultName = 'db:migrate';
protected function configure()
{
-
+ $this->setAliases(['migrate']);
$this->setDescription('Execute all migrations');
}
diff --git a/imperium/Command/RollbackDatabase.php b/imperium/Command/RollbackDatabase.php
index 14a79b7..bc99af1 100644
--- a/imperium/Command/RollbackDatabase.php
+++ b/imperium/Command/RollbackDatabase.php
@@ -13,6 +13,7 @@ namespace Imperium\Command {
protected function configure()
{
+ $this->setAliases(['rollback']);
$this->setDescription('Rollback the latest migration');
}
diff --git a/imperium/Command/RoutesList.php b/imperium/Command/RoutesList.php
index ad4ce1c..9608a96 100644
--- a/imperium/Command/RoutesList.php
+++ b/imperium/Command/RoutesList.php
@@ -20,7 +20,7 @@ namespace Imperium\Command {
protected function configure()
{
- $this->setDescription('List all routes created');
+ $this->setDescription('List all routes created')->setAliases(['routes']);
}
/**
diff --git a/imperium/Command/RunMode.php b/imperium/Command/RunMode.php
new file mode 100644
index 0000000..b5e7014
--- /dev/null
+++ b/imperium/Command/RunMode.php
@@ -0,0 +1,29 @@
+<?php
+
+
+namespace Imperium\Command {
+
+
+ use Imperium\File\File;
+ use Symfony\Component\Console\Command\Command;
+ use Symfony\Component\Console\Input\InputInterface;
+ use Symfony\Component\Console\Output\OutputInterface;
+
+ class RunMode extends Command
+ {
+ protected static $defaultName = 'app:up';
+
+
+ protected function configure()
+ {
+ $this->setDescription('Turn the application in the mode')->setAliases(['up']);
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ return File::put("web/index.php","<?php\n\n\trequire_once dirname(__DIR__) . '/vendor/autoload.php';\n\n\techo app()->run();") === true;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Command/SeedDatabase.php b/imperium/Command/SeedDatabase.php
index 6838521..25286e7 100644
--- a/imperium/Command/SeedDatabase.php
+++ b/imperium/Command/SeedDatabase.php
@@ -12,6 +12,7 @@ namespace Imperium\Command {
protected static $defaultName = 'db:seed';
protected function configure()
{
+ $this->setAliases(['seed']);
$this->setDescription('Seed the database');
}
diff --git a/imperium/Command/Server.php b/imperium/Command/Server.php
index 7cb7141..6e6bf0a 100644
--- a/imperium/Command/Server.php
+++ b/imperium/Command/Server.php
@@ -11,6 +11,7 @@ namespace Imperium\Command {
protected static $defaultName = 'app:run';
protected function configure()
{
+ $this->setAliases(['serve']);
$this->setDescription('Run a development server');
}
diff --git a/imperium/Command/UpdateDatabase.php b/imperium/Command/UpdateDatabase.php
index 461838f..3f04af5 100644
--- a/imperium/Command/UpdateDatabase.php
+++ b/imperium/Command/UpdateDatabase.php
@@ -17,7 +17,7 @@ namespace Imperium\Command {
$this->base = config('db','base');
- $this->setDescription("Update the $this->base database");
+ $this->setDescription("Update the $this->base database")->setAliases(['update']);
}
public function execute(InputInterface $input, OutputInterface $output)
diff --git a/imperium/Connexion/Connect.php b/imperium/Connexion/Connect.php
index dbfe522..af2d052 100644
--- a/imperium/Connexion/Connect.php
+++ b/imperium/Connexion/Connect.php
@@ -6,6 +6,7 @@ namespace Imperium\Connexion {
use PDO;
use PDOException;
use Imperium\Directory\Dir;
+ use Symfony\Component\DependencyInjection\Tests\Compiler\D;
/**
*
@@ -163,12 +164,11 @@ namespace Imperium\Connexion {
public function __construct(string $driver,string $base,string $username,string $password,string $host,string $dump_path)
{
-
$this->dump_path = dirname(config_path()) .DIRECTORY_SEPARATOR . collection(config('app','dir'))->get('db') . DIRECTORY_SEPARATOR . $dump_path;
$this->driver = $driver;
- $this->database = equal($driver,SQLITE) ? dirname($this->dump_path) .DIRECTORY_SEPARATOR . $base : $base;
+ $this->database = equal($driver,SQLITE) ? realpath(dirname(config_path())) .DIRECTORY_SEPARATOR . 'web' .DIRECTORY_SEPARATOR . $base : $base;
$this->username = $username;
@@ -544,27 +544,29 @@ namespace Imperium\Connexion {
}
}
- }
- if (def($database))
- {
- try
- {
- $this->instance = new PDO("$driver:host=$host;dbname=$database",$username,$password);
- }catch (PDOException $e)
+ }else{
+ if (def($database))
{
- return $e->getMessage();
+ try
+ {
+ $this->instance = new PDO("$driver:host=$host;dbname=$database",$username,$password);
+ }catch (PDOException $e)
+ {
+ return $e->getMessage();
+ }
}
- }
- else
- {
- try
- {
- $this->instance = new PDO("$driver:host=$host;dbname=$database",$username,$password);
- }catch (PDOException $e)
+ else
{
- return $e->getMessage();
+ try
+ {
+ $this->instance = new PDO("$driver:host=$host;dbname=$database",$username,$password);
+ }catch (PDOException $e)
+ {
+ return $e->getMessage();
+ }
}
}
+
}else{
return $this->instance;
}
diff --git a/imperium/Dump/Dump.php b/imperium/Dump/Dump.php
index d05fd60..0eb7636 100644
--- a/imperium/Dump/Dump.php
+++ b/imperium/Dump/Dump.php
@@ -114,7 +114,7 @@ namespace Imperium\Dump {
Dir::clear($dump_path);
- $filename = "$dump_path/$database.sql";
+ $filename = equal($driver,SQLITE) ? $dump_path . DIRECTORY_SEPARATOR . \collection(explode('.',collection(explode(DIRECTORY_SEPARATOR,$database))->last()))->begin() .'.sql' :"$dump_path/$database.sql";
switch ($driver)
{
diff --git a/imperium/Import/Import.php b/imperium/Import/Import.php
index 0562d9a..f1aeb44 100644
--- a/imperium/Import/Import.php
+++ b/imperium/Import/Import.php
@@ -59,15 +59,13 @@ namespace Imperium\Import {
/**
* Import constructor.
*
- * @param string $base
- *
* @throws Exception
*/
- public function __construct(string $base = '')
+ public function __construct()
{
$this->connexion = app()->connect();
$this->driver = $this->connexion->driver();
- $this->base = def($base) ? $base : $this->connexion->base();
+ $this->base = $this->connexion->base();
$this->sql_file = sql_file();
}
@@ -100,6 +98,7 @@ namespace Imperium\Import {
return is_not_false(system(" psql -h $host -U $username $base < $sql"));
break;
case Connect::SQLITE:
+
return is_not_false(system("sqlite3 $base < $sql"));
break;
default:
diff --git a/imperium/Model/Model.php b/imperium/Model/Model.php
index 013895d..a4c7af9 100644
--- a/imperium/Model/Model.php
+++ b/imperium/Model/Model.php
@@ -729,7 +729,7 @@ namespace Imperium\Model {
*/
public function find(int $id)
{
- return $this->query()->from($this->current())->mode(Query::SELECT)->where($this->primary(),EQUAL,$id)->use_fetch()->get();
+ return $this->query()->from($this->current())->mode(SELECT)->where($this->primary(),EQUAL,$id)->use_fetch()->get();
}
/**object
diff --git a/mysql.yaml b/mysql.yaml
index 6756b17..4d4db8d 100644
--- a/mysql.yaml
+++ b/mysql.yaml
@@ -2,7 +2,7 @@ driver: mysql
base: zen
username: root
password: root
-dump: 'db/dump'
+dump: 'dump'
host: 'localhost'
hidden_tables: ['migrations']
hidden_bases: []
diff --git a/pgsql.yaml b/pgsql.yaml
index c4a80e6..500e40d 100644
--- a/pgsql.yaml
+++ b/pgsql.yaml
@@ -2,7 +2,7 @@ driver: pgsql
base: zen
username: postgres
password: postgres
-dump: 'db/dump'
+dump: 'dump'
host: 'localhost'
hidden_tables: ['migrations']
hidden_bases: []
diff --git a/phinx.php b/phinx.php
index aa1a22d..cac7977 100644
--- a/phinx.php
+++ b/phinx.php
@@ -1,6 +1,7 @@
<?php
-
-$file = 'db';
+
+$x = app()->connect();
+
return [
"paths" => [
"migrations" => "db/migrations",
@@ -12,12 +13,12 @@ return [
'default_database' => 'development',
'development' =>
[
- "adapter" => config($file,'driver'),
- "host" => config($file,'host'),
- "name" => config($file,'base'),
- "user" => config($file,'username'),
- "pass" => config($file,'password'),
- "port" => config($file,'port'),
+ "adapter" => $x->driver(),
+ "host" => $x->host(),
+ "name" => $x->base(),
+ "user" => $x->user(),
+ "pass" => $x->password(),
+ "port" => config('db','port'),
]
]
]; \ No newline at end of file
diff --git a/sqlite.yaml b/sqlite.yaml
index ee7ed30..3eedf73 100644
--- a/sqlite.yaml
+++ b/sqlite.yaml
@@ -2,7 +2,7 @@ driver: sqlite
base: zen.sqlite3
username:
password:
-dump: 'db/dump'
+dump: 'dump'
host: 'localhost'
hidden_tables: ['migrations','sqlite_sequence']
hidden_bases: []
diff --git a/tests/mysql/app/AppTest.php b/tests/mysql/app/AppTest.php
index 37cad69..3b57ec8 100644
--- a/tests/mysql/app/AppTest.php
+++ b/tests/mysql/app/AppTest.php
@@ -651,13 +651,7 @@ namespace Testing\mysql\app {
$this->assertInstanceOf(Users::class,user($this->postgresql()->connect()));
}
- /**
- * @throws Exception
- */
- public function test_pass()
- {
- $this->assertTrue(pass('root','root'));
- }
+
/**
*
diff --git a/tests/mysql/base/BaseTest.php b/tests/mysql/base/BaseTest.php
index 86ba15e..1c05022 100644
--- a/tests/mysql/base/BaseTest.php
+++ b/tests/mysql/base/BaseTest.php
@@ -92,17 +92,6 @@ namespace Testing\mysql\base {
$this->mysql()->bases()->set_collation($bidon)->change_collation();
$this->mysql()->bases()->set_charset($bidon)->change_charset();
}
- /**
- * @throws \Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->mysql()->bases()->set_charset('utf8')->change_charset());
- $this->assertTrue($this->mysql()->bases()->set_collation('utf8_general_ci')->change_collation());
-
- $this->assertTrue($this->mysql()->change_base_charset('utf8'));
- $this->assertTrue($this->mysql()->change_base_collation('utf8_general_ci'));
- }
}