Note that there are some explanatory texts on larger screens.

plurals
  1. POActive Record implementation of this SQL?
    primarykey
    data
    text
    <p>I am using CodeIgniter. My database is MySQL 5. The SQL statement below works fine, but I am thinking it would not really be compatible with MSSQL, PG, et al. I am wondering if it's possible to implement the statement using the Active Record class in CI, hence making it completely cross database ?</p> <p>I think the "GROUP_CONCAT" is where I'll fall down...</p> <p>EDIT - Found on the CodeIgniter board</p> <blockquote> <p>"It should be noted, however, that CONCAT is database specific. It’s not actually a part of the active record library, although I’m sure it’s supported by most, if not all database engines."</p> </blockquote> <p>I may have to rethink this, as it looks to be not possible using pure Active Record.</p> <pre><code>SELECT system.system_id, system.uuid, system.hostname, system.man_description, system.man_ip_address, system.os_short_name, system.os_full_name, system.man_type, system.man_icon, GROUP_CONCAT(DISTINCT '&lt;a href="', oa_group.group_id, '"&gt;', oa_group.group_description, '&lt;/a&gt;' ORDER BY group_description SEPARATOR ', ') as tag FROM system, oa_group, oa_group_sys WHERE system.system_id IN ( SELECT system.system_id FROM system, oa_group_sys, oa_group, oa_group_user WHERE system.man_status = 'production' AND system.system_id = oa_group_sys.system_id AND oa_group_sys.group_id = oa_group.group_id AND oa_group.group_id = oa_group_user.group_id AND oa_group_user.user_id = '1' ) AND system.system_id = oa_group_sys.system_id AND oa_group_sys.group_id = oa_group.group_id GROUP BY system.system_id </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload