Skip to content

Commit f2ae41c

Browse files
committed
add search process in oop
1 parent 6ae0cae commit f2ae41c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

backend/OOP/SearchProcess.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
class SearchProcess{
3+
private $db;
4+
public function __construct ($dbConnection)
5+
{
6+
$this->db=$dbConnection;
7+
}
8+
public function searchUserByUsername($username) {
9+
$stmt = $this->db->connection->prepare("SELECT * FROM users1 WHERE username = ?");
10+
$stmt->bind_param("s", $username);
11+
$stmt->execute();
12+
$result = $stmt->get_result();
13+
14+
if ($result->num_rows > 0) {
15+
return $result->fetch_all(MYSQLI_ASSOC);
16+
} else {
17+
return [];
18+
}
19+
20+
$stmt->close();
21+
}
22+
}
23+
24+
?>

0 commit comments

Comments
 (0)