use latest dotclear namespace (database)

This commit is contained in:
Jean-Christian Denis 2023-04-23 12:52:34 +02:00
parent 9b6ea2294c
commit 9adb197b2f
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 16 additions and 16 deletions

View file

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias; namespace Dotclear\Plugin\filesAlias;
use dbStruct;
use dcCore; use dcCore;
use dcNsProcess; use dcNsProcess;
use Dotclear\Database\Structure;
use Exception; use Exception;
class Install extends dcNsProcess class Install extends dcNsProcess
@ -35,21 +35,21 @@ class Install extends dcNsProcess
} }
try { try {
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
$s->{My::ALIAS_TABLE_NAME} $s->__get(My::ALIAS_TABLE_NAME)
->blog_id('varchar', 32, false) ->field('blog_id', 'varchar', 32, false)
->filesalias_url('varchar', 255, false) ->field('filesalias_url', 'varchar', 255, false)
->filesalias_destination('varchar', 255, false) ->field('ilesalias_destination', 'varchar', 255, false)
->filesalias_password('varchar', 32, true, null) ->field('filesalias_password', 'varchar', 32, true, null)
->filesalias_disposable('smallint', 0, false, 0) ->field('filesalias_disposable', 'smallint', 0, false, 0)
->primary('pk_filesalias', 'blog_id', 'filesalias_url') ->primary('pk_filesalias', 'blog_id', 'filesalias_url')
->index('idx_filesalias_blog_id', 'btree', 'blog_id') ->index('idx_filesalias_blog_id', 'btree', 'blog_id')
->reference('fk_filesalias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade') ->reference('fk_filesalias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade')
; ;
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $si = new Structure(dcCore::app()->con, dcCore::app()->prefix);
$changes = $si->synchronize($s); $changes = $si->synchronize($s);
return true; return true;

View file

@ -16,7 +16,7 @@ namespace Dotclear\Plugin\filesAlias;
use dcCore; use dcCore;
use dcMedia; use dcMedia;
use dcRecord; use Dotclear\Database\MetaRecord;
use Dotclear\Database\Statement\{ use Dotclear\Database\Statement\{
DeleteStatement, DeleteStatement,
SelectStatement SelectStatement
@ -31,9 +31,9 @@ class Utils
/** /**
* Get aliases records. * Get aliases records.
* *
* @return dcRecord The file alias records * @return MetaRecord The file alias records
*/ */
public static function getAliases(): dcRecord public static function getAliases(): MetaRecord
{ {
// nullsafe // nullsafe
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id; $blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
@ -50,15 +50,15 @@ class Utils
->order('filesalias_url ASC') ->order('filesalias_url ASC')
->select(); ->select();
return is_null($rs) ? dcRecord::newFromArray([]) : $rs; return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
} }
/** /**
* Get alias record. * Get alias record.
* *
* @return dcRecord The alias record * @return MetaRecord The alias record
*/ */
public static function getAlias(string $url): dcRecord public static function getAlias(string $url): MetaRecord
{ {
// nullsafe // nullsafe
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id; $blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
@ -76,7 +76,7 @@ class Utils
->order('filesalias_url ASC') ->order('filesalias_url ASC')
->select(); ->select();
return is_null($rs) ? dcRecord::newFromArray([]) : $rs; return is_null($rs) ? MetaRecord::newFromArray([]) : $rs;
} }
/** /**