Query coder

Categories

Component ID

1939706

Component name

Query coder

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

3719

Component created

Component changed

Component body

Convert SQL query to Drupal Database abstraction layer code.

Dependencies:

  1. Libraries API module
  2. PHP-SQL-Parser (version from 2013-11-30) library

INSTALL:

  1. Download and install Libraries API module
  2. Download PHP-SQL-Parser (version from 2013-11-30) library and unzip it to "sites/all/libraries" folder. Full path must be "sites/all/libraries/PHP-SQL-Parser/php-sql-parser.php"
  3. Download and install "Query coder" module
  4. Go to admin/config/development/query_coder

How To Use

Nice tutorial for this module on webwash.net:
Convert SQL Query Into Dynamic Query Using Query Coder Module

Known issues:

  • INSERT queries must be specified in form "INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)"
  • Not support "->expression()" conditions for UPDATE queries.
  • All tables and fields in SELECT query must be specified with aliases, in other (UPDATE, INSERT, DELETE) queries without aliases
    Example:
    RIGHT: "SELECT * FROM users u"
    NOT RIGHT: "SELECT * FROM users"
  • All combining conditions in SELECT queries must be specified with aliases.
    Example:
    RIGHT: "SELECT COUNT(*) AS user_count FROM users u"
    NOT RIGHT: "SELECT COUNT(*) FROM users u".