मैं कैसे इन प्रश्नों लिखा जाना चाहिए पर कई उदाहरण पढ़ा है, लेकिन मैं इस विशिष्ट पाने के लिए संघर्ष कर रहा हूँ जब bindParam
के लिए एक MySQL पीडीओ क्वेरी
का उपयोग कर चलाने के लिए यह सही तरीका होगा bindParam में की तरह का उपयोग करना एक उपयोगकर्ता से शुरू होने वाले उपयोगकर्ता नाम से मेल खाते हैं?
$term = "a";
$term = "'$term%'";
$sql = "SELECT username
FROM `user`
WHERE username LIKE :term
LIMIT 10";
$core = Connect::getInstance();
$stmt = $core->dbh->prepare($sql);
$stmt->bindParam(':term', $term, PDO::PARAM_STR);
$stmt->execute();
$data = $stmt->fetchAll();
यहां एक नमूना कोड है: https://gist.github.com/arsho/a203e7bc156ea566587361a76038f020 – arsho