How do you manage SQL Queries

后端 未结 10 1699
深忆病人
深忆病人 2020-12-13 05:59

At the moment my code (PHP) has too many SQL queries in it. eg...

// not a real example, but you get the idea...
$results = $db->GetResults(\"SELECT * FRO         


        
10条回答
  •  不思量自难忘°
    2020-12-13 06:18

    I had to clean up a project wich many (duplicate/similar) queries riddled with injection vulnerabilities. The first steps I took were using placeholders and label every query with the object/method and source-line the query was created. (Insert the PHP-constants METHOD and LINE into a SQL comment-line)

    It looked something like this:

    -- @Line:151 UserClass::getuser():

    SELECT * FROM USERS;
    

    Logging all queries for a short time supplied me with some starting points on which queries to merge. (And where!)

提交回复
热议问题