~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-22 22:44:49 UTC
  • Revision ID: deivinsontejeda@gmail.com-20100122224449-8a03r26ppfuz3963
1->Arreglando el find() para que funcione con y sin chain
2->En el DbQuery 
        ->En el método where se recibe un array para realizar las consultas preparadas (Prepared Statement)
        ->se agrega método para obetener los params para enlazar al SQL
        ->Se agrega método column para indicar las columnas que se quiere en la consulta

3->En el DbAdapter en la construcción del Query en el where se hace un implode directo ya que la consulta es preparada

Ejemplo
//Modelo
    public function buscar()
    {
        $this->get()->columns('nombre, id')
                    ->where(array('id > ?'=>2, 'id<?'=>5))
                    ->limit(2);

        //ejecuta un find() personalizado via chain
        return $this->find();
                         
    }

//Otra forma
    public function buscar()
    {
        //ejecuta un find() por defecto
        return $this->find();
    }

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
            
125
125
        } elseif(isset($sqlArray['delete'])) {
126
126
            return $this->_delete($sqlArray);
127
 
            
128
127
        }
129
128
        
130
129
        return NULL;
174
173
            
175
174
            foreach($insert['columns'] as $k => $v) {
176
175
                $columns[] = $k;
177
 
                $values[] = $pdo->quote($v);
 
176
                //$values[] = $pdo->quote($v);
 
177
                $values[] = ":$k";
178
178
            }
179
179
            
180
180
            $columns = implode(', ', $columns);
290
290
            
291
291
                // genera la condicion where partiendo de un array
292
292
                $where = array();
293
 
                foreach($sqlArray['where'] as $k => $v) {
294
 
                    $where[] = "$k=" . $pdo->quote($v);
295
 
                }
296
 
                $where = implode(' AND ', $where);
 
293
                /*foreach($sqlArray['where'] as $k) {
 
294
                    //$where[] = "$k=" . $pdo->quote($v);
 
295
                    $where[] = $k;
 
296
                }*/
 
297
                $where = implode(' AND ', $sqlArray['where']);
297
298
            } else {
298
299
                $where = $sqlArray['where'];
299
300
            }