agelxnash/modx-evo-database

Maintainers

👁 Agel Nash

Package info

github.com/AgelxNash/modx-evo-database

pkg:composer/agelxnash/modx-evo-database

Statistics

Installs: 1 163

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 2

1.5.0 2020-12-03 15:06 UTC

Requires

  • php: >=5.6

Requires (Dev)

Suggests

Provides

None

Conflicts

None

Replaces

None

MIT cb9d9c0e025c33812afe280a8c34a57b0e71d543

databasemysqlimodx

This package is auto-updated.

Last update: 2026-05-29 01:17:13 UTC


README

👁 CMS MODX Evolution
👁 Build Status
👁 StyleCI
👁 Code quality
👁 Code Coverage
👁 Total Downloads
👁 License

Example

MySQLi

$DB = new AgelxNash\Modx\Evo\Database\Database([
 'host' => 'localhost',
 'database' => 'modx',
 'username' => 'homestead',
 'password' => 'secret',
 'prefix' => 'modx_',
 'charset' => 'utf8mb4',
 'method' => 'SET NAMES',
 'collation' => 'utf8mb4_unicode_ci',
]);
$DB->setDebug(true);
$DB->connect();
$table = $DB->getFullTableName('site_content');

$result = $DB->query('SELECT * FROM ' . $table . ' WHERE parent = 0 ORDER BY pagetitle DESC LIMIT 10');
 // or
$result = $DB->select('*', $table, 'parent = 0', 'pagetitle DESC', '10');
 // or
$result = $DB->select(
 ['id', 'pagetitle', 'title' => 'longtitle'],
 ['c' => $table],
 ['parent = 0'],
 'ORDER BY pagetitle DESC',
 'LIMIT 10'
 );
foreach ($DB->makeArray($result) as $item) {
 echo "\t [ DOCUMENT #ID " . $item['id'] . ' ] ' . $item['pagetitle'] . PHP_EOL;
}

Illuminate\Database and Eloquent

composer require "illuminate/database" required when you need to use IlluminateDriver composer require "illuminate/events" required when you need to use observers with Eloquent

$DB = new AgelxNash\Modx\Evo\Database\Database(
 [
 'host' => 'localhost',
 'database' => 'modx',
 'username' => 'homestead',
 'password' => 'secret',
 'prefix' => 'modx_',
 'charset' => 'utf8mb4',
 'method' => 'SET NAMES',
 'collation' => 'utf8mb4_unicode_ci',
 ],
 AgelxNash\Modx\Evo\Database\Drivers\IlluminateDriver::class
);
$DB->connect();

$table = $DB->getFullTableName('site_content');
$result = $DB->query('SELECT * FROM ' . $table . ' WHERE parent = 0 ORDER BY pagetitle DESC LIMIT 10');
foreach ($DB->makeArray($result) as $item) {
 echo "\t [ DOCUMENT #ID " . $item['id'] . ' ] ' . $item['pagetitle'] . PHP_EOL;
}

$results = Illuminate\Database\Capsule\Manager::table('site_content')
 ->where('parent', '=', 0)
 ->orderBy('pagetitle', 'DESC')
 ->limit(10)
 ->get();
foreach ($results as $item) {
 echo "\t [ DOCUMENT #ID " . $item->id . ' ] ' . $item->pagetitle . PHP_EOL;
}

$results = AgelxNash\Modx\Evo\Database\Models\SiteContent::where('parent', '=', 0)
 ->orderBy('pagetitle', 'DESC')
 ->limit(10)
 ->get();
foreach ($results as $item) {
 echo "\t [ DOCUMENT #ID " . $item->id . ' ] ' . $item->pagetitle . PHP_EOL;
}

// create table
Illuminate\Database\Capsule\Manager::schema()->create('users', function ($table) {
 $table->increments('id');
 $table->string('email')->unique();
 $table->timestamps();
});

Read more about

Author

👁 Image

Borisov Evgeniy
Agel_Nash


Laravel, MODX, Security Audit


https://agel-nash.ru
Telegram: @agel_nash
Email: modx@agel-nash.ru