From 0afb2c0046b55c123eafb4ab9ee77efa68d12463 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 06 Jun 2026 17:15:31 +0000
Subject: [PATCH] =Starting the Favourites.js setup, converting previous Northeh stuff to new Registrar, fixing up Square.php integration to match

---
 inc/managers/CustomTable.php |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/inc/managers/CustomTable.php b/inc/managers/CustomTable.php
index e344576..572d8a2 100644
--- a/inc/managers/CustomTable.php
+++ b/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])) {
@@ -184,7 +185,7 @@
 				if (is_array($key)) {
 					$value = $key['value'];
 					// Ensure value is wrapped in parentheses
-					if (!str_starts_with(trim($value), '(')) {
+					if (!str_contains(trim($value), '(`')) {
 						$value = '(`' . $value . '`)';
 					}
 					$parts[] = $key['key'] . ' KEY ' . $value;
@@ -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';

--
Gitblit v1.10.0