~desarrollokumbia/kumbia/ActiveRecord

« back to all changes in this revision

Viewing changes to db_pool/adapters/db_adapter.php

  • Committer: Deivinson Tejeda
  • Date: 2010-01-24 20:53:08 UTC
  • Revision ID: deivinsontejeda@gmail.com-20100124205308-hsovf0apo3pbg3s0
Mejorando el chain where, quedan ahora los metodos where() y whereOr y se puede concatenar los where, ademas se crea un método interno para el DbQuery quien ira armando el los where en el orden como se vayan llamando y para dejar mas facil el where y whereOr solo reciben string asi no liamos a los usarios con array, sin embargo seguimos evaluando
Eje...
    public function consulta()
    {
        $this->get()->where('id < :id2')
                    ->where('id > :id')
                    ->bind(array(':id'=>2, ':id2'=>5));
        return $this->find();
    }
la consulta generada del anterios chain es:
SELECT * FROM prueba WHERE  (id < :id2)  AND (id > :id)

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
        if(isset($sqlArray['where'])) {
287
287
            if(is_array($sqlArray['where'])) {
288
288
                $where = NULL;
289
 
                if(isset($sqlArray['where']['and'])){
290
 
                    $where = implode(' AND ', $sqlArray['where']['and']);
291
 
                }
292
 
                if(isset($sqlArray['where']['or'])){
293
 
                    $where .= implode(' OR ', $sqlArray['where']['or']);
294
 
                }
 
289
                $where = ' ' .  implode(' ', $sqlArray['where']);                
295
290
            } else {
296
291
                $where = $sqlArray['where'];
297
292
            }