Merged in bugfix/PMC-981 (pull request #6995)
PMC-981 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
42
app/Console/Commands/AddParametersTrait.php
Normal file
42
app/Console/Commands/AddParametersTrait.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Maveriks\WebApplication;
|
||||
|
||||
trait AddParametersTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new queue command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$workspace = $this->option('workspace');
|
||||
if (!empty($workspace)) {
|
||||
$webApplication = new WebApplication();
|
||||
$webApplication->setRootDir($this->option('processmakerPath'));
|
||||
$webApplication->loadEnvironment($workspace);
|
||||
}
|
||||
parent::handle();
|
||||
}
|
||||
}
|
||||
39
app/Console/Commands/FailedTableCommand.php
Normal file
39
app/Console/Commands/FailedTableCommand.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Queue\Console\FailedTableCommand as BaseFailedTableCommand;
|
||||
use Illuminate\Support\Composer;
|
||||
|
||||
class FailedTableCommand extends BaseFailedTableCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:failed-table';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue failed-table command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($files, $composer);
|
||||
}
|
||||
}
|
||||
20
app/Console/Commands/FlushFailedCommand.php
Normal file
20
app/Console/Commands/FlushFailedCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\FlushFailedCommand as BaseFlushFailedCommand;
|
||||
|
||||
class FlushFailedCommand extends BaseFlushFailedCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:flush';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
14
app/Console/Commands/ForgetFailedCommand.php
Normal file
14
app/Console/Commands/ForgetFailedCommand.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\ForgetFailedCommand as BaseForgetFailedCommand;
|
||||
|
||||
class ForgetFailedCommand extends BaseForgetFailedCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
20
app/Console/Commands/ListFailedCommand.php
Normal file
20
app/Console/Commands/ListFailedCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\ListFailedCommand as BaseListFailedCommand;
|
||||
|
||||
class ListFailedCommand extends BaseListFailedCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:failed';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
20
app/Console/Commands/RestartCommand.php
Normal file
20
app/Console/Commands/RestartCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand;
|
||||
|
||||
class RestartCommand extends BaseRestartCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:restart';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
14
app/Console/Commands/RetryCommand.php
Normal file
14
app/Console/Commands/RetryCommand.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\RetryCommand as BaseRetryCommand;
|
||||
|
||||
class RetryCommand extends BaseRetryCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
39
app/Console/Commands/TableCommand.php
Normal file
39
app/Console/Commands/TableCommand.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Queue\Console\TableCommand as BaseTableCommand;
|
||||
use Illuminate\Support\Composer;
|
||||
|
||||
class TableCommand extends BaseTableCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:table';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue table command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($files, $composer);
|
||||
}
|
||||
}
|
||||
31
app/Console/Commands/WorkCommand.php
Normal file
31
app/Console/Commands/WorkCommand.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand;
|
||||
use Illuminate\Queue\Worker;
|
||||
|
||||
class WorkCommand extends BaseWorkCommand
|
||||
{
|
||||
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue work command.
|
||||
*
|
||||
* @param \Illuminate\Queue\Worker $worker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Worker $worker)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($worker);
|
||||
}
|
||||
}
|
||||
8
app/Jobs/Email.php
Normal file
8
app/Jobs/Email.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class Email extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
8
app/Jobs/EmailEvent.php
Normal file
8
app/Jobs/EmailEvent.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class EmailEvent extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
21
app/Jobs/QueuedClosure.php
Normal file
21
app/Jobs/QueuedClosure.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
use Illuminate\Queue\SerializableClosure;
|
||||
|
||||
abstract class QueuedClosure extends CallQueuedClosure
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \Illuminate\Queue\SerializableClosure $closure
|
||||
*/
|
||||
public function __construct(Closure $closure)
|
||||
{
|
||||
parent::__construct(new SerializableClosure($closure));
|
||||
}
|
||||
}
|
||||
8
app/Jobs/ScriptTask.php
Normal file
8
app/Jobs/ScriptTask.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ScriptTask extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
8
app/Jobs/ServiceTask.php
Normal file
8
app/Jobs/ServiceTask.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ServiceTask extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
24
app/Providers/WorkCommandServiceProvider.php
Normal file
24
app/Providers/WorkCommandServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Console\Commands\WorkCommand;
|
||||
use Illuminate\Queue\QueueServiceProvider;
|
||||
|
||||
class WorkCommandServiceProvider extends QueueServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Overrides "register" method from Queue provider.
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
parent::register();
|
||||
|
||||
//Extend command "queue:work".
|
||||
$this->app->extend('command.queue.work', function ($command, $app) {
|
||||
return new WorkCommand($app['queue.worker']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,6 @@ return array(
|
||||
'ToolBar' => ToolBar::class,
|
||||
'Tree' => PmTree::class,
|
||||
'triggerLibrary' => TriggerLibrary::class,
|
||||
'Upgrade' => Upgrade::class,
|
||||
'workspaceTools' => WorkspaceTools::class,
|
||||
'wsBase' => WsBase::class,
|
||||
'wsResponse' => WsResponse::class,
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
"laravel/framework": "5.7.*",
|
||||
"luracast/restler": "^3.0",
|
||||
"bshaffer/oauth2-server-php": "v1.0",
|
||||
"colosa/pmUI": "release/3.3.1-dev",
|
||||
"colosa/MichelangeloFE": "release/3.3.1-dev",
|
||||
"colosa/pmdynaform": "release/3.3.1-dev",
|
||||
"colosa/pmUI": "release/3.4.0-dev",
|
||||
"colosa/MichelangeloFE": "release/3.4.0-dev",
|
||||
"colosa/pmdynaform": "release/3.4.0-dev",
|
||||
"google/apiclient": "1.1.6",
|
||||
"dapphp/securimage": "^3.6",
|
||||
"psr/log": "1.0.0",
|
||||
@@ -48,6 +48,7 @@
|
||||
"smarty/smarty": "2.6.30",
|
||||
"pdepend/pdepend": "@stable",
|
||||
"chumper/zipper": "^1.0",
|
||||
"php-imap/php-imap": "^3.0",
|
||||
"nikic/php-parser": "3.1.5",
|
||||
"laravel/tinker": "^1.0"
|
||||
},
|
||||
@@ -66,7 +67,7 @@
|
||||
"ProcessMaker\\": "workflow/engine/src"
|
||||
},
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"App\\": "app/",
|
||||
"Maveriks\\": "framework/src/Maveriks/",
|
||||
"Tests\\": "tests/"
|
||||
},
|
||||
|
||||
527
composer.lock
generated
527
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,8 @@ return [
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
'debug' => env('APP_DEBUG', false),
|
||||
'cache_lifetime' => env('APP_CACHE_LIFETIME', 60),
|
||||
'key' => env('APP_KEY', 'base64:rU28h/tElUn/eiLY0qC24jJq1rakvAFRoRl1DWxj/kM='),
|
||||
'cipher' => 'AES-256-CBC',
|
||||
'timezone' => 'UTC',
|
||||
'providers' => [
|
||||
FilesystemServiceProvider::class,
|
||||
@@ -19,11 +21,14 @@ return [
|
||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||
Laravel\Tinker\TinkerServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
],
|
||||
|
||||
'aliases' => [
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -58,6 +58,7 @@ workflow/engine/methods/cases/casesDemo.php
|
||||
workflow/engine/methods/cases/cases_Scheduler_Save.php
|
||||
workflow/engine/methods/cases/cases_Scheduler_Update.php
|
||||
workflow/engine/methods/cases/proxyPMTablesSaveFields.php
|
||||
workflow/engine/methods/cases/proxyProcessList.php
|
||||
workflow/engine/methods/cases/saveFormSupervisor.php
|
||||
workflow/engine/methods/controls/buscador.php
|
||||
workflow/engine/methods/dbConnections/genericDbConnections.php
|
||||
|
||||
87
config/queue.php
Normal file
87
config/queue.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue API supports an assortment of back-ends via a single
|
||||
| API, giving you convenient access to each back-end using the same
|
||||
| syntax for every one. Here you may define a default connection.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection information for each server that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with Laravel. You are free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'JOBS_PENDING',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => 'localhost',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'block_for' => 0,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'your-queue-name'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control which database and table are used to store the jobs that
|
||||
| have failed. You may change them to any database / table you wish.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'database' => env('DB_CONNECTION', 'workflow'),
|
||||
'table' => 'JOBS_FAILED',
|
||||
],
|
||||
|
||||
];
|
||||
37
database/factories/ConfigurationFactory.php
Normal file
37
database/factories/ConfigurationFactory.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Model factory for a configuration
|
||||
*/
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\Configuration;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
$factory->define(Configuration::class, function(Faker $faker) {
|
||||
return [
|
||||
'CFG_UID' => $faker->randomElement(['AUDIT_LOG', 'EE']),
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => '',
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'USR_UID' => G::generateUniqueID(),
|
||||
'APP_UID' => G::generateUniqueID(),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Configuration::class, 'userPreferencesEmpty', function (Faker $faker) {
|
||||
// Grab a user if random
|
||||
$users = User::all();
|
||||
if (!empty($users)) {
|
||||
$user = factory(User::class)->create();
|
||||
} else {
|
||||
$user = $users->random();
|
||||
}
|
||||
return [
|
||||
'CFG_UID' => 'USER_PREFERENCES',
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => '',
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'APP_UID' => '',
|
||||
];
|
||||
});
|
||||
|
||||
23
database/factories/EmailServerFactory.php
Normal file
23
database/factories/EmailServerFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\EmailServer::class, function(Faker $faker) {
|
||||
return [
|
||||
'MESS_UID' => G::generateUniqueID(),
|
||||
'MESS_ENGINE' => '',
|
||||
'MESS_SERVER' => '',
|
||||
'MESS_PORT' => 0,
|
||||
'MESS_INCOMING_SERVER' => '',
|
||||
'MESS_INCOMING_PORT' => 0,
|
||||
'MESS_RAUTH' => 0,
|
||||
'MESS_ACCOUNT' => '',
|
||||
'MESS_PASSWORD' => '',
|
||||
'MESS_FROM_MAIL' => '',
|
||||
'MESS_FROM_NAME' => '',
|
||||
'SMTPSECURE' => 'No',
|
||||
'MESS_TRY_SEND_INMEDIATLY' => 0,
|
||||
'MAIL_TO' => '',
|
||||
'MESS_DEFAULT' => 0,
|
||||
];
|
||||
});
|
||||
17
database/factories/ProcessFilesFactory.php
Normal file
17
database/factories/ProcessFilesFactory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\ProcessFiles::class, function(Faker $faker) {
|
||||
return [
|
||||
'PRF_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => '',
|
||||
'PRF_UPDATE_USR_UID' => '',
|
||||
'PRF_PATH' => '',
|
||||
'PRF_TYPE' => '',
|
||||
'PRF_EDITABLE' => 1,
|
||||
'PRF_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRF_UPDATE_DATE' => $faker->dateTime(),
|
||||
];
|
||||
});
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Foundation\Http\Kernel;
|
||||
use Luracast\Restler\Format\UploadFormat;
|
||||
use Luracast\Restler\RestException;
|
||||
use Maveriks\Util;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services;
|
||||
@@ -612,6 +613,11 @@ class WebApplication
|
||||
|
||||
\Propel::init(PATH_CONFIG . "databases.php");
|
||||
|
||||
/**
|
||||
* JobsManager
|
||||
*/
|
||||
JobsManager::getSingleton()->init();
|
||||
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
$attributes = $oPluginRegistry->getAttributes();
|
||||
Bootstrap::LoadTranslationPlugins(defined('SYS_LANG') ? SYS_LANG : "en", $attributes);
|
||||
|
||||
0
gulliver/bin/gulliver
Executable file → Normal file
0
gulliver/bin/gulliver
Executable file → Normal file
@@ -393,19 +393,20 @@ class database extends database_base
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a sentence to add indexes or primary keys
|
||||
* Generate a sentence to add indexes or primary keys
|
||||
*
|
||||
* @param string $table table name
|
||||
* @param string $indexName index name
|
||||
* @param array $keys array of keys
|
||||
* @param string $indexType the index type
|
||||
*
|
||||
* @return string sql sentence
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public function generateAddKeysSQL($table, $indexName, $keys)
|
||||
public function generateAddKeysSQL($table, $indexName, $keys, $indexType = 'INDEX')
|
||||
{
|
||||
try {
|
||||
$indexType = 'INDEX';
|
||||
if ($indexName === 'primaryKey' || $indexName === 'PRIMARY') {
|
||||
$indexType = 'PRIMARY';
|
||||
$indexName = 'KEY';
|
||||
@@ -519,13 +520,15 @@ class database extends database_base
|
||||
}
|
||||
|
||||
/**
|
||||
* execute a sql query
|
||||
* Execute a sql query
|
||||
*
|
||||
* @param string $query
|
||||
* @param bool $throwError
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function executeQuery($query)
|
||||
public function executeQuery($query, $throwError = false)
|
||||
{
|
||||
$this->logQuery($query);
|
||||
|
||||
@@ -545,7 +548,11 @@ class database extends database_base
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
$this->logQuery($exception->getMessage());
|
||||
return [];
|
||||
if ($throwError) {
|
||||
throw $exception;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,4 +1019,98 @@ class database extends database_base
|
||||
}
|
||||
return $flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate drop trigger SQL
|
||||
*
|
||||
* @param string $triggerName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDropTrigger($triggerName)
|
||||
{
|
||||
return "DROP TRIGGER IF EXISTS `{$triggerName}`;";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate alter table with or without adding the indexes
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param array $columns
|
||||
* @param array $indexes
|
||||
* @param array $fulltextIndexes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateAddColumnsSql($tableName, $columns, $indexes = [], $fulltextIndexes = [])
|
||||
{
|
||||
$indexesAlreadyAdded = [];
|
||||
$sql = 'ALTER TABLE ' . $this->sQuoteCharacter . $tableName . $this->sQuoteCharacter . ' ';
|
||||
foreach ($columns as $columnName => $parameters) {
|
||||
if (isset($parameters['Type']) && isset($parameters['Null'])) {
|
||||
$sql .= 'ADD COLUMN ' . $this->sQuoteCharacter . $columnName . $this->sQuoteCharacter . ' ' . $parameters['Type'];
|
||||
if ($parameters['Null'] == 'YES') {
|
||||
$sql .= ' NULL';
|
||||
} else {
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
}
|
||||
if (isset($parameters['AutoIncrement']) && $parameters['AutoIncrement']) {
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
if (isset($parameters['PrimaryKey']) && $parameters['PrimaryKey']) {
|
||||
$sql .= ' PRIMARY KEY';
|
||||
$indexesAlreadyAdded[] = $columnName;
|
||||
}
|
||||
if (isset($parameters['Unique']) && $parameters['Unique']) {
|
||||
$sql .= ' UNIQUE';
|
||||
}
|
||||
|
||||
// We need to check the property AI
|
||||
if (isset($parameters['AI'])) {
|
||||
if ($parameters['AI'] == 1) {
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
} else {
|
||||
if ($parameters['Default'] != '') {
|
||||
$sql .= " DEFAULT '" . $parameters['Default'] . "'";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($parameters['Default'])) {
|
||||
$sql .= " DEFAULT '" . $parameters['Default'] . "'";
|
||||
}
|
||||
}
|
||||
$sql .= ', ';
|
||||
}
|
||||
// Add the normal indexes if are not "primaryKeys" already added
|
||||
foreach ($indexes as $indexName => $indexColumns) {
|
||||
$indexType = 'INDEX';
|
||||
if ($indexName === 'primaryKey' || $indexName === 'PRIMARY') {
|
||||
$indexType = 'PRIMARY';
|
||||
$indexName = 'KEY';
|
||||
// If is primary key is not needed add a new index, the column already was added like primary key
|
||||
if (count($indexColumns) == 1 && $indexesAlreadyAdded == $indexColumns) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$sql .= 'ADD ' . $indexType . ' ' . $indexName . ' (';
|
||||
foreach ($indexColumns as $column) {
|
||||
$sql .= $this->sQuoteCharacter . $column . $this->sQuoteCharacter . ', ';
|
||||
}
|
||||
$sql = substr($sql, 0, -2);
|
||||
$sql .= '), ';
|
||||
}
|
||||
// Add the "fulltext" indexes always
|
||||
foreach ($fulltextIndexes as $indexName => $indexColumns) {
|
||||
$sql .= 'ADD FULLTEXT ' . $indexName . ' (';
|
||||
foreach ($indexColumns as $column) {
|
||||
$sql .= $this->sQuoteCharacter . $column . $this->sQuoteCharacter . ', ';
|
||||
}
|
||||
$sql = substr($sql, 0, -2);
|
||||
$sql .= '), ';
|
||||
}
|
||||
$sql = rtrim($sql, ', ');
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class DBConnection
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function DBConnection($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
public function __construct($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
{
|
||||
$this->errorLevel = $errorLevel;
|
||||
if ($type == null) {
|
||||
|
||||
@@ -47,9 +47,9 @@ class DBRecordSet
|
||||
* @param string $intResult Database recordset default value = false
|
||||
* @return void
|
||||
*/
|
||||
function DBRecordSet ($intResult = null)
|
||||
public function __construct($intResult = null)
|
||||
{
|
||||
$this->SetTo( $intResult );
|
||||
$this->SetTo($intResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,12 +52,12 @@ class DBSession
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
function DBSession ($objConnection = null, $strDBName = '')
|
||||
public function __construct($objConnection = null, $strDBName = '')
|
||||
{
|
||||
if ($strDBName != '') {
|
||||
$strDBName = $objConnection->db->_db;
|
||||
}
|
||||
$this->setTo( $objConnection, $strDBName );
|
||||
$this->setTo($objConnection, $strDBName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user