How to pass an array value in bind_param in mysqli?

Asked

Viewed 83 times

0

I am doing so, but always error because of array, someone knows how to solve it:

public function Verificar(string $tabela,string $parametros,array ...$usuario) {
            $this->Query = $this->Conexao->prepare("SELECT * FROM usuarios WHERE $tabela");
            $this->Query->bind_param($parametros,$usuario);
            $this->Query->execute();
            $this->ResultadoUser = $this->Query->get_result();
            return $this->ResultadoUser;
        }
  • vc cannot directly pass an array to bind_param().

  • there is some solution in this case ?

  • Depending on the php version you have a simpler option see here

1 answer

0

If the solution proposed in the comment by rray does not help, you may consider using a framework. Recommend, use, the Pixie. Below is an example of SELECT:

$query = QB::table('my_table')->where('nome', 'Jose');
$query->count();

It may not be the answer you expect, but it is an option to consider. To do what you want to pass multiple parameters at the same time you can pass in the format expected by Pixie.

View documentation with several examples.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.