daos

Implement OrangeHRM DAO methods with Doctrine QueryBuilder and Paginator conventions.

1.1k|746|Updated Jan 5, 2017
One-click install
npx skills add https://github.com/orangehrm/orangehrm --skill daos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: daos
Source: https://github.com/orangehrm/orangehrm/tree/main/.agents/skills/daos
Command: npx skills add https://github.com/orangehrm/orangehrm --skill daos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OrangeHRM enforces a strict, consistent data access pattern across all its plugins, and deviating from this pattern leads to inconsistent code, performance bugs (especially with joined queries and pagination), and avoidable errors like SQL injection or incorrect transaction handling. This Skill eliminates the guesswork by providing a complete reference for the project's standard DAO implementation practices.

Core Features & Use Cases

  • Standard DAO Pattern Reference: Covers plugin-specific <Name>Dao classes extending BaseDao, the EntityManagerHelperTrait method catalog, and the full lifecycle of DAO methods from API request to data return.
  • QueryBuilder Best Practices: Documents join patterns, expression builder usage (orX/andX/like/concat/in/isNull), conditional joins, parameter binding, and result retrieval strategies including partial DTO projections for blob columns.
  • Pagination & Transaction Guidance: Explains how to use Paginator for accurate counts on joined queries, QueryBuilderWrapper for returning buildable query builders, and explicit transaction management for multi-step atomic writes.
  • Use Case Example: Use this Skill when you need to implement a new paginated, filterable employee list endpoint, debug a query that returns incorrect counts due to JOIN duplicates, or wrap a bulk employee import in a transaction to ensure data consistency.

Quick Start

Use the daos skill to write a new DAO method that retrieves a paginated list of job titles filtered by name, with accurate total count for the UI.

Frequently Asked Questions about daos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a paginated and filtered list endpoint using Doctrine QueryBuilder in OrangeHRM?

To write a paginated, filtered list endpoint in OrangeHRM, implement a custom DAO method using Doctrine QueryBuilder with expression builders for filtering and the Paginator class to retrieve accurate total counts for joined queries.

Why does my OrangeHRM pagination count return incorrect totals when using JOIN queries?

Joined query counts in OrangeHRM return incorrect totals due to duplicate rows from JOIN operations. Use Doctrine's Paginator class to compute accurate counts by handling join duplication properly instead of counting raw query results directly.

How do I manage atomic multi-step database writes safely in an OrangeHRM plugin?

To manage atomic multi-step database writes in OrangeHRM, wrap the operations within explicit transaction boundaries provided by the EntityManagerHelperTrait to ensure data consistency and rollback on failure.

What is the standard DAO pattern for implementing data access logic in OrangeHRM plugins?

The standard OrangeHRM DAO pattern involves creating plugin-specific classes extending BaseDao, utilizing the EntityManagerHelperTrait, and using QueryBuilderWrapper to return buildable query objects safely.

How do I prevent SQL injection when binding parameters in OrangeHRM QueryBuilder queries?

Prevent SQL injection in OrangeHRM QueryBuilder queries by applying safe parameter binding practices, passing all user inputs through Doctrine's parameter binding methods rather than concatenating strings into DQL statements.

When should I use a custom QueryBuilder query instead of a simple repository lookup in OrangeHRM?

Use a custom QueryBuilder query in OrangeHRM when you need complex conditional joins, filtered pagination, or partial DTO projections for blob columns, and rely on simple repository lookups only for basic primary key fetches.