[eluser]Randy Casburn[/eluser]
I wasn't digging on you. No we're just back to this...
Quote:It would be interesting to see a front end design tool scouring through all the Model files correcting queries (teehee)
There are many ways to accomplish one goal. What makes one method any better or worse than another is determined by one's frame of reference.
===============
One class, one method:
Assuming the final URI segment is used to identify the page name from the database (routing used to establish this for instance):
From within your Controller some where:
Code:
/* i.e. http://mydomain.com/whatchuwant */
$this->_getPageData($this->uri->segment($this->uriSegments));
This is also a method of your controller:
Code:
/* requests page data for page named
* 'whatchuwant' from model
*/
function _getPageData($page){
$this->load->model('myModel');
$this->pageData = $this->myModel->getPageDataFromDB($page);
}
Then the model would look like this:
Code:
function getPageDataFromDB($page){
$query = $this->db->getWhere('content','alias="'.$page.'"');
$aPageMeta = $query->row_array();
return $aPageMeta;
}
Finally, back to your controller, call your views thus...
Code:
$this->load->view('myview', ( $this->pageData)? $this->pageData : $this->page404() );
===========
That's it. You can call any number of pages out of your DB with only this code and nothing else.
There is an unmistakable simplicity in this. As I said above, your frame of reference will be different than mine. Please consider that before you decompose every line of this demonstrative code.