Welcome Guest, Not a member yet? Register   Sign In
URI Segments
#7

[eluser]hykoh[/eluser]
xwero offers me the best solution i wanted :-)

my solution now:

products_controller.php:
Code:
class Products extends Controller {
/* index etc. skipped */
  function show() {
    $filter = $this->uri->uri_to_assoc();
    
    $data['arrProducts'] = $this->produkte_model->showProducts($filter);
/* etc. ... */
}

product_model:

Code:
class Products_model extends Model {
function showProducts($filter = '') {
    $db = new pdo_helper(MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_HOST, 'mysql');
    $sql_filter = '';
    
    foreach($filter as $fKey => $fVal) {
      switch($fKey) {
        case 'cat':
        $sql_filter .= "AND produkte.kategorie_id = '".$fVal."'";
        break;

        case 'lieferant':
        $sql_filter .= "AND produkte.kategorie_id = '".$fVal."'";
        break;

        default:
        $sql_filter = '';
        break;
      }
    }
}

Works fine for me Smile But maybe there's something to optimise ?

Greets


Messages In This Thread
URI Segments - by El Forum - 10-02-2008, 04:30 AM
URI Segments - by El Forum - 10-02-2008, 04:54 AM
URI Segments - by El Forum - 10-02-2008, 05:11 AM
URI Segments - by El Forum - 10-02-2008, 05:25 AM
URI Segments - by El Forum - 10-02-2008, 05:40 AM
URI Segments - by El Forum - 10-02-2008, 05:51 AM
URI Segments - by El Forum - 10-02-2008, 06:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB