lundi 28 décembre 2015

Laravel query builder - Migrating from traditional SQL

So I'm slowly starting to migrate my website to Laravel and I', finding it very challenging to say the least. I now have to rewrite all my traditional sql statements and the documentation doesn't give simple snippets of common sql queries. Below is my login script that I've spent hours trying to figure out how to convert..

$query = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$result = mysqli_query($connection, $query);
$count = mysqli_num_rows($result);

if ($count > 0) {
    $row = mysqli_fetch_array($result);

    if ($row['verified'] == 1) {
        echo "Valid";
    } elseif ($row['verified'] == 0) {
        echo "not aValid";
    }
} elseif ($count == 0) {
    echo "not Valid";
}

Any help or guidance will greatly be appreciated. I need to be pointed in the right direction as to how to do simple queries like this one as my site is riddled with a lot of them. I'm starting to think I may have written my logic in a bad way to begin with.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1RNQHQd
via IFTTT

Aucun commentaire:

Enregistrer un commentaire