{
  "id": "10",
  "content": [
    {
      "type": "heading",
      "text": "Databases with PDO & Prepared Statements"
    },
    {
      "type": "text",
      "html": "Use PDO to connect and query databases securely with prepared statements."
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;?php\n$pdo = new PDO('mysql:host=localhost;dbname=app','user','pass',[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);\n$stmt = $pdo-&gt;prepare('SELECT * FROM users WHERE email = :email');\n$stmt-&gt;execute([':email' =&gt; $email]);\n$rows = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);\n</code></pre>"
    },
    {
      "type": "text",
      "html": "Prepared statements separate data from SQL, reducing injection risk."
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Which PHP extension provides a unified DB interface with prepared statements?",
        "options": [
          {
            "id": "a",
            "text": "PDO"
          },
          {
            "id": "b",
            "text": "cURL"
          },
          {
            "id": "c",
            "text": "GD"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Prepared statements help prevent:",
        "options": [
          {
            "id": "a",
            "text": "SQL injection"
          },
          {
            "id": "b",
            "text": "CSS bugs"
          },
          {
            "id": "c",
            "text": "HTTP errors"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}