protected function makeRelation($concepto, $parent)
 {
     if ($this->sthExistsRel == null) {
         $query = "SELECT count(*) as count FROM relaciones_maestros WHERE id_inf = ? AND id_sup = ? ";
         $this->sthExistsRel = DB::prepare($query);
     }
     $objCount = DB::executeFetch($this->sthExistsRel, array($concepto->id, $parent->id));
     if ($objCount->count == 1) {
         // ya existe la relaciĆ³n no se agrega.
         return false;
     }
     if ($this->sthInsertRel == null) {
         $query = "INSERT INTO relaciones_maestros (id_sup,id_inf,cantidad,factor,custom_nombre) values (?,?,?,?,?) ";
         $this->sthInsertRel = DB::prepare($query);
     }
     $params = array();
     $params[] = $parent->id;
     $params[] = $concepto->id;
     $params[] = $concepto->cantidad;
     $params[] = $concepto->factor;
     $params[] = isset($concepto->custom_nombre) ? $concepto->custom_nombre : '';
     $this->sthInsertRel->execute($params);
     //echo 'se creo relacion '. $concepto->id . ' ---> '. $parent->id .'\n<br/>' ;
     return true;
 }
Example #2
0
 public static function prepareExecuteFetch($query, $params = null)
 {
     $sth = DB::prepare($query);
     return DB::executeFetch($sth, $params);
 }