Where do you see possible SQL injections here?
Oct 10, 2018
6
Level 1
Prevent Sql injection attacks
Here i have mentioned my query, this query can sql injection attacks possible
class AutoSuggestHelper {
/**
* sendEmail
*
* Method uder for sending emails to users
*
*/
public static function autoSuggest($data)
{
$term = $data['q'];
$type = $data['type'];
$results = array();
switch ($type) {
case 'chiefComplaint':
$queries = DB::table('chief_complaints')
->select('id', 'cc_text as value')
->where('cc_text', 'LIKE', '%' . $term . '%')
->take(15)->get();
break;
case 'questions':
$queries = DB::table('users')
->select('id', 'email as value')
->where('email', 'LIKE', '%' . $term . '%')
->where('user_role', '=', 'D')
->where('is_account_active', '=', 'Y')
->take(15)->get();
break;
case 'questionscategory':
$queries = DB::table('patients')
->select('id', 'email as value')
->where('email', 'LIKE', '%' . $term . '%')
->where('is_account_active', '=', 'Y')
->take(15)->get();
break;
case 'userPhone':
$queries = DB::table('patients')
//->select('id', 'contact_number as value')
->select('id', DB::raw('TRIM(LEADING "+" FROM SUBSTRING_INDEX(`contact_number`, "-", -1)) as value'))
->where('contact_number', 'LIKE', '%' . $term . '%')
->take(15)->get();
break;
}
foreach ($queries as $query) {
$results[] = $query->value;
}
return $results;
}
}
Please or to participate in this conversation.