Jump to content

PDO question


Naez

Recommended Posts

I'm not sure what you mean when you say extending PDO... Personally, i'd just do something like this (it's all in mysql, just convert over to PDO)

 

<?php

class classSql {

  private $link;
  public $error, $count = 0;
  
  public function __construct($s = FALSE, $u = FALSE, $p = FALSE, $db = FALSE) {
    if ($s == FALSE || $u == FALSE || $p == FALSE || $db == FALSE) // Assumes db connection is already made
      $this->link = FALSE;
    else {
      $this->link = mysql_connect($s, $u, $p);
      mysql_select_db($db, $this->link);
      // Add error checking obivously, this is just an example
    }
  }
  
  public function select ($table, $columns, $misc = FALSE) {
    foreach ($columns as $column) {
      // Convert array to `colname`, `colname2`.. ect
    }
    mysql_query($builtString, $this->link);
    // add error checking, if there's no error, increment count
    $this->count++;
  }

  // add more functions for INSERT, UPDATE, DELETE ect...

}

?>

 

 

then at the end of the script, $this->count will hold the total queries executed. This is just a quick sample, don't use anything i've posted above in an actual script please ;)

Link to comment
https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502577
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.