consecutive in a php function

0

Hello, I have a problem that I urgently need to solve, I hope you can help me.

I have 2 related tables the ones in a call def_client clients are added and they have a field called no_portage that indicates a range of the client

in the other table called def_consecutive I have the fields of:

  • rank
  • from
  • up to
  • counter

the client's rank makes it assigned in this table and for which the counter must indicate how many clients are in that range

I have a function that since it gives which is the number that I have in the counter

public function getConsecutiveByRange($rango)
{
   $sql ="SELECT contador FROM def_consecutivo WHERE rango_numeros=:rango";
   return $this->getResponseQueryOne($sql,["rango"=>$rango]);
}

Now I need to do the function that will help me increase the counter when a client is added.

I remain in expectation of your opinions Greetings.

    
asked by Luis Enrique Gómez Pérez 06.12.2018 в 15:51
source

1 answer

0

and if ...

function addClient($contador,$rango)
{
 $contador += 1;
 $sql = "update def_consecutivo set contador = $contador where rango_numeros = $rango"
 // ejecutas tu query y haces tu return de lo que desees
}

and for decrement

function remClient($contador,$rango)
{
 $contador -= 1;
 $sql = "update def_consecutivo set contador = $contador where rango_numeros = $rango"
 // ejecutas tu query y haces tu return de lo que desees
}

Greetings.

    
answered by 06.12.2018 в 16:45