SQL Query Builder

Local plugins ::: local_sqlquerybuilder
Maintained by Konrad Ebel
It enables other plugins to build SQL queries using a builder class.
Latest release:
7 downloads
1 fans
Current versions available: 1

The plugin allows you to write complex queries using a query builder for other plugins.
It is a library for other plugins and does not include any user features itself. 

 The query builder's syntax is based on Laravel.
It makes writing SQL queries in Moodle easier.

For example it supports statements like:
$this->db = di::get(i_db::class);
$this->db->table('user')->where('firstname', '=', 'Paul')->get();

But also more complex examples like:
$this->db = di::get(i_db::class);
$this->db->table('enrol', 'e')
            ->distinct()
            ->join('user_enrolments', ['ue.enrolid', '=', 'e.id'], 'ue')
            ->join('user', ['u.id', '=', 'ue.userid'], 'u')
            ->select('ue.userid')
            ->where('ue.status', '=', 0)
            ->where('u.deleted', '=', 0)
            ->where('u.suspended', '=', 0)
            ->where_currently_active('ue.timestart', 'ue.timeend')
            ->order_asc("ue.userid")
            ->get();

Todos

  • Allow subqueries in where statement
  • Allow equal functions (case sensitive, text functions ...)
  • Add union function
  • Provide more raw methods to make the plugin more flexible
  • JSON Functions
  • Update functionality
  • Delete functionality
  • Create functionality

Screenshots

Screenshot #0

Contributors

Konrad Ebel (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments

Show comments
Please login to post comments