You are here

abstract class DB in Anti Spam by CleanTalk 9.1.x

Same name in this branch
  1. 9.1.x src/lib/Cleantalk/Common/DB.php \Cleantalk\Common\DB
  2. 9.1.x src/lib/Cleantalk/ApbctDrupal/DB.php \Cleantalk\ApbctDrupal\DB
Same name and namespace in other branches
  1. 8.4 src/lib/Cleantalk/Common/DB.php \Cleantalk\Common\DB

CleanTalk abstract Data Base driver. Shows what should be inside. Uses singleton pattern.

@version 1.0 @author Cleantalk team (welcome@cleantalk.org) @copyright (C) 2014 CleanTalk team (http://cleantalk.org) @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html

Hierarchy

  • class \Cleantalk\Common\DB

Expanded class hierarchy of DB

See also

https://github.com/CleanTalk/php-antispam

5 files declare their use of DB
AntiCrawler.php in src/lib/Cleantalk/Common/Firewall/Modules/AntiCrawler.php
AntiFlood.php in src/lib/Cleantalk/Common/Firewall/Modules/AntiFlood.php
Firewall.php in src/lib/Cleantalk/Common/Firewall/Firewall.php
FirewallModule.php in src/lib/Cleantalk/Common/Firewall/FirewallModule.php
FirewallUpdater.php in src/lib/Cleantalk/Common/Firewall/FirewallUpdater.php

File

src/lib/Cleantalk/Common/DB.php, line 17

Namespace

Cleantalk\Common
View source
abstract class DB {
  private static $instance;

  /**
   * @var array Processed result
   */
  public $result = array();

  /**
   * @var string Database prefix
   */
  public $prefix = '';
  public function __construct() {
  }
  public function __clone() {
  }
  public function __wakeup() {
  }
  public static function getInstance() {
    if (!isset(self::$instance)) {
      self::$instance = new static();
      self::$instance
        ->init();
    }
    return self::$instance;
  }

  /**
   * Alternative constructor.
   * Initilize Database object and write it to property.
   * Set tables prefix.
   */
  protected abstract function init();

  /**
   * Set $this->query string for next uses
   *
   * @param $query
   * @return $this
   */
  public abstract function set_query($query);

  /**
   * Safely replace place holders
   *
   * @param string $query
   * @param array  $vars
   *
   * @return $this
   */
  public abstract function prepare($query, $vars = array());

  /**
   * Run any raw request
   *
   * @param $query
   *
   * @return bool|int Raw result
   */
  public abstract function execute($query);

  /**
   * Fetchs first column from query.
   * May receive raw or prepared query.
   *
   * @param bool $query
   * @param bool $response_type
   *
   * @return array|object|void|null
   */
  public abstract function fetch($query = false, $response_type = false);

  /**
   * Fetchs all result from query.
   * May receive raw or prepared query.
   *
   * @param bool $query
   * @param bool $response_type
   *
   * @return array|object|null
   */
  public abstract function fetch_all($query = false, $response_type = false);
  public abstract function get_last_error();

}

Members

Namesort descending Modifiers Type Description Overrides
DB::$instance private static property
DB::$prefix public property
DB::$result public property
DB::execute abstract public function Run any raw request 1
DB::fetch abstract public function Fetchs first column from query. May receive raw or prepared query. 1
DB::fetch_all abstract public function Fetchs all result from query. May receive raw or prepared query. 1
DB::getInstance public static function
DB::get_last_error abstract public function 1
DB::init abstract protected function Alternative constructor. Initilize Database object and write it to property. Set tables prefix. 1
DB::prepare abstract public function Safely replace place holders 1
DB::set_query abstract public function Set $this->query string for next uses 1
DB::__clone public function
DB::__construct public function
DB::__wakeup public function