Files
FreshRSS/app/Models/Factory.php
Alexandre Alapetite c76a318193 CLI to export/import any database to/from SQLite (#2496)
* CLI to export/import any database to/from SQLite

Require PHP 5.5+ https://github.com/FreshRSS/FreshRSS/pull/2495

* Travis

* Execution rights

* Fix wrong static fields

* Fix MySQL bad default buffering

https://stackoverflow.com/questions/6895098/pdo-mysql-memory-consumption-with-large-result-set/6935271#6935271
https://php.net/manual/ref.pdo-mysql

* Fix count on progression

* Avoid static DB information

To ease working with two DBs at the same time

* Less static, simplify

Needs some testing

* Small corrections

* Special case for SQLite to SQLite

* Modify special case for SQLite

* Remove special case for SQLite

More uniform logic for the 3 databases.
Fix wrong DROP TABLE for SQLite.

* Drop indexes

* Revert "Drop indexes"

This reverts commit f28d2bae09.

* Fix deletion

* Fix classic export

* Update cli/README.md

Co-Authored-By: Marien Fressinaud <dev@marienfressinaud.fr>

* Addressing part of review

* Remove goto 😢

* Travis

* Comment for SQLite case

* Fix missing fields when inserting
2019-09-15 21:36:53 +02:00

72 lines
1.8 KiB
PHP

<?php
class FreshRSS_Factory {
public static function createUserDao($username = null) {
return new FreshRSS_UserDAO($username);
}
public static function createCategoryDao($username = null) {
return new FreshRSS_CategoryDAO($username);
}
public static function createFeedDao($username = null) {
$conf = Minz_Configuration::get('system');
switch ($conf->db['type']) {
case 'sqlite':
return new FreshRSS_FeedDAOSQLite($username);
default:
return new FreshRSS_FeedDAO($username);
}
}
public static function createEntryDao($username = null) {
$conf = Minz_Configuration::get('system');
switch ($conf->db['type']) {
case 'sqlite':
return new FreshRSS_EntryDAOSQLite($username);
case 'pgsql':
return new FreshRSS_EntryDAOPGSQL($username);
default:
return new FreshRSS_EntryDAO($username);
}
}
public static function createTagDao($username = null) {
$conf = Minz_Configuration::get('system');
switch ($conf->db['type']) {
case 'sqlite':
return new FreshRSS_TagDAOSQLite($username);
case 'pgsql':
return new FreshRSS_TagDAOPGSQL($username);
default:
return new FreshRSS_TagDAO($username);
}
}
public static function createStatsDAO($username = null) {
$conf = Minz_Configuration::get('system');
switch ($conf->db['type']) {
case 'sqlite':
return new FreshRSS_StatsDAOSQLite($username);
case 'pgsql':
return new FreshRSS_StatsDAOPGSQL($username);
default:
return new FreshRSS_StatsDAO($username);
}
}
public static function createDatabaseDAO($username = null) {
$conf = Minz_Configuration::get('system');
switch ($conf->db['type']) {
case 'sqlite':
return new FreshRSS_DatabaseDAOSQLite($username);
case 'pgsql':
return new FreshRSS_DatabaseDAOPGSQL($username);
default:
return new FreshRSS_DatabaseDAO($username);
}
}
}