Empfehlungen: Erweiterte Suche

Before find mit not-Bedingungen

Datenbankobjekte strukturieren und validieren

Before find mit not-Bedingungen

Beitragvon SeGoTe » Fr 18. Mär 2011, 16:55

Hallo,
ich stehe zurzeit vor folgendem Problem: Ich möchte mit beforeFind imm alle Kategorien bis auf die Kategorie 15 ausgeben. Folgendes funktioniert leider noch nicht:

Code: Alles auswählen
function beforeFind(&$queryData){
        $conditions = $queryData['conditions'];

        if (!is_array($conditions)) {
            if (!$conditions) {
                $conditions = array();
            } else {
                $conditions = array($conditions);
            }
        }

        if (!isset($conditions['c_id']) && !isset($conditions[$this->alias . '.c_id'])) {
            $conditions[$this->alias . '.c_id'] = array('NOT' => 15);
        }
   
        $queryData['conditions'] = $conditions;
        return true;
    }


Wie genau muss ich das ändern, damit es funktioniert?

Danke schonmal für eure Hilfe
SeGoTe
 
Beiträge: 11
Registriert: Di 25. Jan 2011, 19:19

Re: Before find mit not-Bedingungen

Beitragvon euromark » Fr 18. Mär 2011, 17:12

andersrum:
'NOT' => array(conditions)

analog zu AND bzw OR
euromark
 
Beiträge: 643
Registriert: Fr 27. Jun 2008, 22:17
Wohnort: München
CakePHP-Version: 2.x
OS: Windows

Re: Before find mit not-Bedingungen

Beitragvon SeGoTe » Sa 19. Mär 2011, 15:23

Sry aber kannst du das noch ein bisschen genauer erklären?

Ich habe jetzt folgendes gemacht, aber es funktioniert nicht:
Code: Alles auswählen
$conditions[$this->alias . '.c_id']['NOT'] = 15;
SeGoTe
 
Beiträge: 11
Registriert: Di 25. Jan 2011, 19:19


Zurück zu Models

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast

cron