NanoMVC

Custom Database Plugin

If you want to use a custom database plugin instead of the built-in PDO-based one, follow these steps:

  1. Create a new plugin file
    Create a new file in:
    /myapp/plugins/nanomvc_mydb.php or /myfiles/plugins/​nanomvc_mydb.php
  2. Extend the PDO plugin
    In your new file, define your class by extending the built-in PDO class:
    class NanoMVC_MYDB extends NanoMVC_PDO {
      // Override or extend methods here
    }
  3. Modify the logic
    Adjust or extend the functionality to match your database system or preferences.
  4. Update the config
    Open your database configuration:
    /myapp/configs/​config_database.php
    and change the plugin name:
    $config['yourpool']['plugin'] = 'NanoMVC_MYDB';

Result: NanoMVC will now load your custom database class NanoMVC_MYDB automatically on each request, inheriting the base functionality of NanoMVC_PDO.

← to Plugins to Extending NanoMVC Classes →

← Back to Documentation