Skip to content

Instantly share code, notes, and snippets.

@scottcorgan
Created December 21, 2011 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottcorgan/1506630 to your computer and use it in GitHub Desktop.
Save scottcorgan/1506630 to your computer and use it in GitHub Desktop.
Dynamic Causes
$campaigns = array();
$sql = "SELECT * FROM svn_posts WHERE post_type = 'shirts' AND post_date < now() ORDER BY ID DESC LIMIT 10";
$query = $this->db->query($sql);
// create organized arrays of campaign data
foreach($query->result() as $campaign){
$sql = 'SELECT * FROM svn_postmeta WHERE post_id = ' . $campaign->ID;
$results = $this->db->query($sql)->result();
$meta = array();
// loop through meta results and organize them
foreach($results as $result){
$meta[$result->meta_key] = $result->meta_value;
}
// this array holds all the campaign info
$campaigns[$campaign->ID] = array(
'campaign' => $campaign,
'meta' => $meta
);
}
// this array doesn't work.
// need to work on the organization of the meta data
return $campaigns;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment