You are here

DB.php in Anti Spam by CleanTalk 9.1.x

File

src/lib/Cleantalk/ApbctDrupal/DB.php
View source
<?php

namespace Cleantalk\ApbctDrupal;

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() {
  }

}

Classes

Namesort descending Description
DB