Domanda

in modo da poter cercare valori concreti facendo

        $recordset= Model::find('all', array(
            'conditions' => array(
                'condition' => $somevalue
            ) 
        ))

Tuttavia, che cosa devo fare se voglio abbinare su un valore parziale?
in questo momento, ho fatto ricorso a scrivere query me stesso, a la:

$abc = Connections::get('default')->
   read('SELECT * FROM myTable WHERE condition LIKE "%partial string%"');
È stato utile?

Soluzione

Ecco come faccio uno SQL 'come' la ricerca:

$user = User::find('all', array(
        'conditions' => array(
            'first_name' => array('like' => '%yeun%'))
        )
);

'come' è la parola chiave, là.

, che potrebbero generare una query come:

SELECT * FROM `users` AS `Users` WHERE (`first_name` like '%yeun%');

La speranza che aiuta.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top