I need to create a view in MySQL that can be accessed as a readonly entity in Espo. The view definition is extremely complex and cannot be created using Espo's filters. Is there any built-in functionality for this? If not, what would be the best approach? I imagine I could create an entity in Espo containing the same fields as the view, then replace the entity's table in the database with a view of the same name. From Espo's perspective, it would look like a regular table but the records would be populated dynamically. Is this correct, or is there a better way to accomplish this?
Custom Database Views
Collapse
X
-
You can use SqlExecutor https://github.com/espocrm/espocrm/b...nager.php#L423. The source code is documented and type hinted, it can be used w/o a separate documentation.If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.Comment
-
You can also create a collection from an SQL: https://github.com/espocrm/espocrm/b...actory.php#L58
All column names in an SQL result should correspond to entity attribute names.
IMPORTANT: Beware of a possible SQL injection vulnerability. Better to avoid using raw SQLs at all.Last edited by yuri; 08-25-2024, 07:11 AM.If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.Comment
Comment