MysqliDb::orWhere PHP Method

orWhere() public method

This method allows you to specify multiple (method chaining optional) OR WHERE statements for SQL queries.
public orWhere ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=' ) : MysqliDb
$whereProp string The name of the database field.
$whereValue mixed The value of the database field.
$operator string Comparison operator. Default is =
return MysqliDb
    public function orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=')
    {
        return $this->where($whereProp, $whereValue, $operator, 'OR');
    }

Usage Example

コード例 #1
0
echo '		<link rel="stylesheet" type="text/css" href="css/login_form.css">' . "\n";
echo '	</head>' . "\n";
echo '	<body>' . "\n";
if (isset($_POST['submitted'])) {
    $submited = $_POST['submitted'];
    $name = explode(" ", $_POST['name']);
    $pass = $_POST['pass'];
    if (isset($pass) && !empty($pass)) {
        if (isset($name) && !empty($name[0])) {
            if (count($name) >= 1 && count($name) <= 2) {
                if (count($name) > 1) {
                    $db->where('fName', $name[0]);
                    $db->where('lName', $name[1]);
                } else {
                    $db->where('fName', $name);
                    $db->orWhere('lName', $name);
                }
                $user = $db->getOne("Users");
                $hash = $user['password'];
                if (password_verify($pass, $hash)) {
                    echo 'Password is valid!';
                    $_SESSION['user'] = new User($user['id'], $user['fName'], $user['lName'], $user['admin']);
                } else {
                    echo 'Invalid password.';
                }
            } else {
                echo "invalid Name given";
            }
        } else {
            echo "You must enter a name";
        }
All Usage Examples Of MysqliDb::orWhere