Your problem is about classes. Internal libraies accepts macros. External Libraries no. Why? Because external are not parsed but SC parser, but internal and SC apps yes.
SC parser reads files and substitute macros by predefined code. (like globals are changed for $this->var) All events are binded AFAIR to specific functions of a SC object. I mean, internally, SC uses classes (not very good, but this is another story). When you mark an internal library, on generation, the code of the internal library is parsed and injected in the SC object. Probably, when you use a class on an “internal”, in the code generated, a class is created inside another class, and AFAIK this is not allowed.
You have several options.
- Separate database operations from class and encapsulate on your internal (and you use your class on it).
- Use your class on an external, and pass connection info on instantiation.
TL;TR
Macros can be used on internals
You can’t define classes on internals.
Macros can’t be used on externals
You can define classes on externals.