~desarrollokumbia/kumbia/ActiveRecord

« back to all changes in this revision

Viewing changes to active_record2/active_record2.php

  • Committer: Emilio Silveira
  • Date: 2010-09-05 05:44:16 UTC
  • Revision ID: emilio.rst@gmail.com-20100905054416-k0zvmrxtvajdl59v
Adicionados metodos
delete y deleteByPK

Show diffs side-by-side

added added

removed removed

Lines of Context:
704
704
                return FALSE;
705
705
        }
706
706
        
 
707
        /**
 
708
     * Elimina el registro correspondiente al objeto
 
709
     * 
 
710
     * @return Bool 
 
711
     */
 
712
        public function delete()
 
713
        {       
 
714
                // Objeto de consulta
 
715
                $dbQuery = new DbQuery();
 
716
                // Establece condicion de busqueda con clave primaria
 
717
                $this->_wherePK($dbQuery);
 
718
                
 
719
                // Ejecuta la consulta con el query utilizado para el exists
 
720
                if($this->query($dbQuery->delete())) {
 
721
                        return $this;
 
722
                }
 
723
                
 
724
                return FALSE;
 
725
        }
 
726
        
 
727
        /**
 
728
     * Elimina el registro por medio de la clave primaria
 
729
     * 
 
730
         * @param string $value
 
731
     * @return Bool 
 
732
     */
 
733
        public function deleteByPK($value)
 
734
        {       
 
735
                // Objeto de consulta
 
736
                $dbQuery = new DbQuery();
 
737
                
 
738
                // Obtiene la clave primeria
 
739
                $pk = $this->metadata()->getPK();
 
740
                
 
741
                // Establece la condicion
 
742
                $dbQuery->where("$pk = :pk_$pk")->bindValue("pk_$pk", $value);
 
743
                
 
744
                // Ejecuta la consulta con el query utilizado para el exists
 
745
                if($this->query($dbQuery->delete())) {
 
746
                        return $this;
 
747
                }
 
748
                
 
749
                return FALSE;
 
750
        }
707
751
}