0
I have the following difficulty, in my application, when executing the registration function, when I type some text with enclosed quotes, the query does not work.
Follow the code below:
Here I take the values passed by the controller, using the __get().
PortfolioDAO.php:
public function alterarPortfolio(Portfolio $portfolio)
{
    $alterar_imagem = ($portfolio->__get('imagem') != '' ? ", imagem = '{$portfolio->__get('imagem')}'" : '');
    $values = "
                empresa = '{$portfolio->__get('empresa')}',
                link = '{$portfolio->__get('link')}',
                tipo_servico = '{$portfolio->__get('tipo_servico')}'
                {$alterar_imagem}
            ";
    $this->alterar($portfolio->__get('id'), $values);
}
Here is the query:
Model.php:
public function alterar($id, $values)
{
    $query = "UPDATE {$this->tabela} SET {$values} WHERE id = {$id}";
    $stmt = $this->db->prepare($query);
    echo $query;
    $stmt->execute();
}
Remembering that, data registration usually occurs, the problem is when I add a simple quotes in the input.
I sent you a reply, but I also suggest you search for sql Injection. Because, this kind of implementation can generate security vulnerabilities.
– phduarte