How Do I Extend Csqliteschema?

I want to add some additional functionality to the SQLite schema without changing the Yii source files. How would I do this?

[s]From a quick search through the code base, it looks like it’ll be quite tricky.

Search for CSqliteSchema in the frame work files and you’ll find it’s referenced directly in CDbConnection (easy to extend), YiiBase (problematic) and yiilite (problematic if you use it).

I think your only real option if you absolutely need the functionality is to fork the Yii repository and maintain a copy yourself, pulling in updates from the official repository when they’re stable. Otherwise, you’ll be better off finding a workaround for whatever you’re trying to achieve, using the built in functionality.

I’d be interested to hear from other Yii devs or the core team regarding this.[/s]


Actually, I think the references in YiiBase and yiilite are irrelevant, they just provide the paths to the core classes. That means you’d only have to extend CSqliteSchema and CDbConnection.

Your steps would be:

  1. Extend CSqliteSchema and store in your components directory.

  2. Extend CDbConnection and override the contents of the array $driverMap to use your new SqliteSchema class.

  3. Update your config so that your DB configuration uses your new DbConnection class.

I found that I didn’t have to extend the CDbConnection as well, I can just pass the $driverMap in the config file.