+ return self::getClass(Database::class)->count($table, $condition);
+ }
+
+ /**
+ * Build the table query substring from one or more tables, with or without a schema.
+ *
+ * Expected formats:
+ * - table
+ * - [table1, table2, ...]
+ * - [schema1 => table1, schema2 => table2, table3, ...]
+ *
+ * @param string|array $tables
+ * @return string
+ */
+ public static function buildTableString($tables)
+ {
+ if (is_string($tables)) {
+ $tables = [$tables];
+ }
+
+ $quotedTables = [];
+
+ foreach ($tables as $schema => $table) {
+ if (is_numeric($schema)) {
+ $quotedTables[] = self::quoteIdentifier($table);
+ } else {
+ $quotedTables[] = self::quoteIdentifier($schema) . '.' . self::quoteIdentifier($table);
+ }
+ }
+
+ return implode(', ', $quotedTables);
+ }
+
+ /**
+ * Escape an identifier (table or field name)
+ *
+ * @param $identifier
+ * @return string
+ */
+ public static function quoteIdentifier($identifier)
+ {
+ return '`' . str_replace('`', '``', $identifier) . '`';