Jake Vanderwerf
5 days ago a9b3b28d001941921aa70d37fdc87c758a163a44
inc/managers/CustomTable.php
@@ -49,15 +49,16 @@
    *
    * @example CustomTable::for('favourites')->insert($data);
    */
   public static function for(string $tableName): self
   public static function for(string $tableName, bool $user = false, bool $auth = false, bool $useTransactions = false): self
   {
      if (!isset(self::$instances[$tableName])) {
         self::$instances[$tableName] = new self($tableName);
         self::$instances[$tableName] = new self($tableName, $user, $auth, $useTransactions);
      }
      return self::$instances[$tableName];
   }
   public static function destroyInstance(string $tableName):void
   {
      if (isset(self::$instances[$tableName])) {
@@ -260,7 +261,7 @@
    * @param string $tableName Table name without prefix/BASE (e.g., 'favourites', 'notifications')
    * @param bool $useTransactions Whether to auto-wrap operations in transactions
    */
   public function __construct(string $tableName, bool $useTransactions = false)
   public function __construct(string $tableName, bool $user = false, bool $auth = false, bool $useTransactions = false)
   {
      global $wpdb;
      $this->wpdb = $wpdb;
@@ -269,6 +270,12 @@
      $this->useTransactions = $useTransactions;
      $this->cache = Cache::for($tableName);
      if ($user) {
         $this->cache->user();
      }
      if ($auth) {
         $this->cache->auth();
      }
      $usersStatus = $this->wpdb->get_row("SHOW TABLE STATUS LIKE '{$this->wpdb->users}'");
      $parentCollation = $usersStatus->Collation ?? 'utf8mb4_general_ci';