Created
January 21, 2014 23:09
-
-
Save nocturnalact/8550394 to your computer and use it in GitHub Desktop.
Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static function search($toid, $query) | |
| { | |
| $db = parent::getDB(); | |
| $sql = "SELECT * | |
| FROM my_messages | |
| WHERE message_date LIKE '%$query%' OR | |
| message_subject LIKE '%$query%' OR | |
| message_content LIKE '%$query%' ) | |
| ORDER BY message_date DESC | |
| LIMIT 10"; | |
| if ($stmt = $db->prepare($sql)) { | |
| // $query = '%' . strip_tags($query) . '%'; | |
| // $query = '%' . trim($query) . '%'; | |
| $stmt->bindParam(1, $toid, \PDO::PARAM_STR); | |
| $stmt->bindParam(2, $query, \PDO::PARAM_STR); | |
| $stmt->bindParam(3, $query, \PDO::PARAM_STR); | |
| $stmt->bindParam(4, $query, \PDO::PARAM_STR); | |
| $stmt->execute(); | |
| return $stmt->fetchAll(); | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment