Created
June 27, 2012 16:05
-
-
Save mmcachran/5a9a459aea335494fb71 to your computer and use it in GitHub Desktop.
Expression Engine 2 Queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetch Channel Fields | |
SELECT | |
fg.group_id, | |
fg.group_name, | |
cf.field_id, | |
cf.field_label, | |
cf.field_order, | |
cf.field_name, | |
cf.field_type | |
FROM | |
exp_field_groups fg | |
LEFT JOIN | |
exp_channel_fields cf | |
ON fg.group_id = cf.group_id | |
ORDER BY fg.group_name, cf.field_order ASC | |
# Example Usage | |
<?php | |
public function fetch_channel_fields() | |
{ | |
$data = array(); | |
$query = " | |
SELECT | |
fg.group_id, | |
fg.group_name, | |
cf.field_id, | |
cf.field_label, | |
cf.field_order, | |
cf.field_name, | |
cf.field_type | |
FROM | |
exp_field_groups fg | |
LEFT JOIN | |
exp_channel_fields cf | |
ON fg.group_id = cf.group_id | |
ORDER BY fg.group_name, cf.field_order ASC | |
"; | |
$fields = $this->EE->db->query($query); | |
if( $fields->num_rows() > 0 ) | |
{ | |
foreach( $fields->result_array() as $row ) | |
{ | |
$data[ $row['group_id'] ][ $row['field_id'] ] = $row; | |
} | |
} | |
return print_r($data); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment