<?php
 abstract class vB_dB_QueryDefs { use vB_Trait_NoSerialize; protected ?vB_dB_Logger $logger; protected $db_type = ''; protected $table_data = []; protected $query_data = []; public function __construct(?vB_dB_Logger $logger = null) { $this->logger = $logger; } public function getTableData() { return $this->table_data; } public function getQueryData() { return $this->query_data; } protected function getResultSet($db, $sql, $tag = '') { return $this->getResultSetInternal($db, $sql, $tag, false, true); } protected function getResultSetReplica($db, $sql, $tag = '') { return $this->getResultSetInternal($db, $sql, $tag, true, true); } protected function getResultSetUnbuffered($db, $sql, $tag = '') { return $this->getResultSetInternal($db, $sql, $tag, false, false); } private function getResultSetInternal($db, $sql, $tag, $useReplica, $buffered) { if ($tag) { $sql .= "\n/** $tag" . (defined('THIS_SCRIPT') ? '- ' . THIS_SCRIPT : '') . '**/'; } if ($this->logger) { $this->logger->log($sql); } $resultclass = 'vB_dB_' . $this->db_type . '_Result'; $result = new $resultclass($db, $sql, $useReplica, $buffered); return $result; } protected function executeWriteQuery($db, $sql, $tag = '') { if ($tag) { $sql .= "\n/** $tag" . (defined('THIS_SCRIPT') ? '- ' . THIS_SCRIPT : '') . '**/'; } if ($this->logger) { $this->logger->log($sql); } return $db->query_write($sql); } protected function getQueryBuilder($db) { $className = 'vB_Db_' . $this->db_type . '_QueryBuilder'; return new $className($db, false); } } 