Simple friend, you will wear the cloister Where
mysql.
Let me give you an example using a code to find a user (with Pdo).
$hostDB = "mysql:host=localhost;dbname=opentagv3";
$usuarioServidor = "root";
$senhaServidor = "123456";
try {
$conexao = new PDO($hostDB, $usuarioServidor, $senhaServidor);
$conexao->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $erroNaConexao) {
echo $erroNaConexao->getMessage();
echo "<br>"."Erro ao Conectar com o Banco de Dados";
}
function buscaUsuarioPorEmail($email){
$select = $this->conexao->prepare("SELECT * FROM usuarios WHERE email='$email'");
$select->setFetchMode(PDO::FETCH_ASSOC);
$select->execute();
$usuario = $select->fetch();
return $usuario;
}
That one select
says so: "Return me all users who have this email".. and my function receives the variable email as a parameter. If at the end of the function return null
, the user with that email does not exist.
In your case it would be..
public function verificar($name){
$select = $this->conexao->prepare("SELECT * FROM slug where slug_name='$name'");
$select->setFetchMode(PDO::FETCH_ASSOC);
$select->execute();
$slug= $select->fetch();
return $slug;
}
I hope I’ve helped.
I changed my answer, notice that the quotation mark is missing in your query....
– MagicHat