sysel/nette-database-myisam

Nette-Database-MyISAM - MyISAM driver for Nette Database

v1.3.0 2016-05-28 09:30 UTC

This package is not auto-updated.

Last update: 2024-12-21 17:59:00 UTC


README

Build Status

Nette Database doesn't support MySQL MyISAM tables by default because this database storage doesn't store information about foreign keys. Unfortunately, there are still servers which support only MyISAM storage tables because they don't consume too many system resources. This driver enables you to use Nette database on those servers.

Requirements

  • Nette for PHP 5.6+ (tested on version 2.4.0)
  • table's referenced columns names shall be in format table_columnName, like author_id or shall have @refs table.columnName in column's comment. The schema can look like:
|          Category                |
| Column name  | Column comment    |
+----------------------------------+
| id           | Category id       |
| name         | Category name     |

|            Text                                 |
| Column name  | Column comment                   |
+-------------------------------------------------+
| id           | Text id                          |
| category_id  | Some comment                     |
| category     | @refs category.id Some comment :)|
| text         | Text content                     |

Installation

Download and copy driver to libs/Sysel/Nette-Database-MyISAM dir or somewhere else where robot loader can find it. Or use composer

composer require sysel/nette-database-myisam

Use

Create database connection:

$options = [
    'driverClass' => '\\Sysel\\Nette\\Database\\Drivers\\MySqlMyIsamDriver',
];
$connection = new \Nette\Database\Connection(
        'mysql:host='.$servername.';dbname='.$database,
        $user,
        $password,
        $options
    );

Or you can add it to you config.neon:

database:
    default:
        dsn: '%database.driver%:host=%database.host%;dbname=%database.database%'
        user: %database.user%
        password: %database.password%
        conventions: discovered
        autowired: true
        options:
            driverClass: Sysel\Nette\Database\Drivers\MySqlMyIsamDriver

Running tests

Please use Composer to download all dependencies.

composer update

Than run Nette Tester with your php.ini file configuration. The configuration is required for correct PDO class use.

# Linux users
vendor/bin/tester -c tests/php-unix.ini tests
# Windows users
vendor/bin/tester -c tests/php-win.ini tests

Known limitations

Getting relations from information schema is not very effective therefore using cache storage is recommended. Despite of that first run can still take several seconds.