I’ve done that previously in my CI controller and also tested my working script (outside the CI framwork), the latter works with both the first not at all.
How do we forward that issue to one of the CI/Expression Engine Gurus? Maybe they know about an issue, like config setting for database, or similar… ???