PDO SELECT DISTINCT guery

Hello,
I can’t run the following PDO query
I’m trying to switch from MySQLi to PDO
Can you help me

      $amplifier_markasorgu = $PDO->prepare("
      SELECT DISTINCT
      markalar.urun_markasi
      FROM multiswitch_amplifier
      JOIN markalar ON multiswitch_amplifier.amplifier_markasi = markalar.id
      ORDER BY markalar.urun_markasi ASC");

      $amplifier_marka_array = array();
      if ($result = $PDOdb->prepare($amplifier_markasorgu)) {
      $adet = $amplifier_markasorgu->fetchColumn();
      if ($adet > 0) {
        while ($row = $amplifier_markasorgu->fetch()){
      $amplifier_marka_array[] = $row['urun_markasi'];
      }
      }
      }

For a query that you are supplying external, unknown, dynamic values to, you use a prepared query, with a place-holder in the sql query statement for each value. You first call the pdo ->prepare() method, to send the sql query statement to the database server, where it gets parsed for errors and the execution phase is planned, then you call the pdostatement ->execute() method to actually run the query.

For a query that does not have any external, unknown, dynamic values being supplied to it, you just call the pdo ->query() method.

-> execute() worked when I added this
Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service