Is there a better, more “Standard” way to perform SQL queries in PHP without using a framework?

前端 未结 8 974
借酒劲吻你
借酒劲吻你 2021-01-27 09:02

For the longest time, I\'ve been using the following basic formatting for SQL queries within my PHP:

$sql = \"SELECT * FROM `user-data` WHERE `id` = \'\".$id.\"\         


        
相关标签:
8条回答
  • 2021-01-27 09:41

    PDO is a good, solid, secure solution that many frameworks build off of. If you're going to start from the bottom, PDO is a solid foundation.

    0 讨论(0)
  • 2021-01-27 09:41

    Try:

    $stat2 = <<<SQL
    SELECT *  from YOUR.DET_TABLE
    WHERE ID = ?
    ORDER BY ID, EFF_DT
    SQL;
      $d_cur = $conn->prepare($stat2);
      $status   = $d_cur->execute(array($selected));
    
    0 讨论(0)
提交回复
热议问题