You are here

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/ApbctDrupal/DB.php \Cleantalk\ApbctDrupal\DB

Hierarchy

  • class \Cleantalk\Common\DB
    • class \Cleantalk\ApbctDrupal\DB

Expanded class hierarchy of DB

2 files declare their use of DB
BootSubscriber.php in src/EventSubscriber/BootSubscriber.php
CleantalkFuncs.php in src/CleantalkFuncs.php

File

src/lib/Cleantalk/ApbctDrupal/DB.php, line 5

Namespace

Cleantalk\ApbctDrupal
View source
class DB extends \Cleantalk\Common\DB {

  /**
   * Alternative constructor.
   * Initilize Database object and write it to property.
   * Set tables prefix.
   */
  protected function init() {
    $this->prefix = \Drupal::service('database')
      ->tablePrefix();
  }

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

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

  /**
   * Run any raw request
   *
   * @param $query
   *
   * @return bool|int Raw result
   */
  public function execute($query) {
    $this->db_result = \Drupal::service('database')
      ->query($query);
    return $this->db_result;
  }

  /**
   * Fetchs first column from query.
   * May receive raw or prepared query.
   *
   * @param bool $query
   * @param bool $response_type
   *
   * @return array|object|void|null
   */
  public function fetch($query = false, $response_type = false) {
    $this->result = \Drupal::service('database')
      ->query($query)
      ->fetchAssoc();
    return $this->result;
  }

  /**
   * Fetchs all result from query.
   * May receive raw or prepared query.
   *
   * @param bool $query
   * @param bool $response_type
   *
   * @return array|object|null
   */
  public function fetch_all($query = false, $response_type = false) {
    $this->db_result = \Drupal::service('database')
      ->query($query);
    $this->result = array();
    while ($row = $this->db_result
      ->fetchAssoc()) {
      $this->result[] = $row;
    }
    return $this->result;
  }
  public 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 public function Run any raw request Overrides DB::execute
DB::fetch public function Fetchs first column from query. May receive raw or prepared query. Overrides DB::fetch
DB::fetch_all public function Fetchs all result from query. May receive raw or prepared query. Overrides DB::fetch_all
DB::getInstance public static function
DB::get_last_error public function Overrides DB::get_last_error
DB::init protected function Alternative constructor. Initilize Database object and write it to property. Set tables prefix. Overrides DB::init
DB::prepare public function Safely replace place holders Overrides DB::prepare
DB::set_query public function Set $this->query string for next uses Overrides DB::set_query
DB::__clone public function
DB::__construct public function
DB::__wakeup public function