From baefea88df4db61160874199d1894c8247b9e105 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 22 Jul 2023 13:54:42 +0000 Subject: [PATCH] Use the Index DbTools version for list prepare thing. --- src/Changelog/Changelog.php | 5 +++-- src/Config/DbConfig.php | 9 +++++---- src/Profile/ProfileFields.php | 11 ++++++----- utility.php | 6 ------ 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Changelog/Changelog.php b/src/Changelog/Changelog.php index 8322f0d..2aa977b 100644 --- a/src/Changelog/Changelog.php +++ b/src/Changelog/Changelog.php @@ -4,6 +4,7 @@ namespace Misuzu\Changelog; use InvalidArgumentException; use RuntimeException; use Index\DateTime; +use Index\Data\DbTools; use Index\Data\IDbConnection; use Index\Data\IDbResult; use Misuzu\DbStatementCache; @@ -122,7 +123,7 @@ class Changelog { $query .= (++$args > 1 ? ' AND' : ' WHERE'); $query .= sprintf( ' change_id IN (SELECT change_id FROM msz_changelog_change_tags WHERE tag_id IN (%s))', - msz_where_in_list($tags) + DbTools::prepareListString($tags) ); } $stmt = $this->cache->get($query); @@ -177,7 +178,7 @@ class Changelog { $query .= (++$args > 1 ? ' AND' : ' WHERE'); $query .= sprintf( ' change_id IN (SELECT change_id FROM msz_changelog_change_tags WHERE tag_id IN (%s))', - msz_where_in_list($tags) + DbTools::prepareListString($tags) ); } $query .= ' GROUP BY change_created, change_id ORDER BY change_created DESC, change_id DESC'; diff --git a/src/Config/DbConfig.php b/src/Config/DbConfig.php index 5925d78..8133723 100644 --- a/src/Config/DbConfig.php +++ b/src/Config/DbConfig.php @@ -4,6 +4,7 @@ namespace Misuzu\Config; use RuntimeException; use InvalidArgumentException; use Index\Data\DataException; +use Index\Data\DbTools; use Index\Data\IDbConnection; use Index\Data\IDbStatement; use Index\Data\IDbResult; @@ -57,7 +58,7 @@ class DbConfig implements IConfig { $stmt = $this->cache->get(sprintf( 'SELECT COUNT(*) FROM msz_config WHERE config_name IN (%s)', - msz_where_in_list($nameCount) + DbTools::prepareListString($nameCount) )); for($i = 0; $i < $nameCount; ++$i) $stmt->addParameter($i + 1, $names[$i]); @@ -83,7 +84,7 @@ class DbConfig implements IConfig { $nameCount = count($names); $stmt = $this->cache->get(sprintf( 'DELETE FROM msz_config WHERE config_name IN (%s)', - msz_where_in_list($nameCount) + DbTools::prepareListString($nameCount) )); for($i = 0; $i < $nameCount; ++$i) @@ -143,7 +144,7 @@ class DbConfig implements IConfig { $stmt = $this->cache->get(sprintf( 'SELECT config_name, config_value FROM msz_config WHERE config_name IN (%s)', - msz_where_in_list($nameCount) + DbTools::prepareListString($nameCount) )); for($i = 0; $i < $nameCount; ++$i) $stmt->addParameter($i + 1, $names[$i]); @@ -267,7 +268,7 @@ class DbConfig implements IConfig { $stmt = $this->cache->get(sprintf( 'REPLACE INTO msz_config (config_name, config_value) VALUES %s', - msz_where_in_list($valueCount, '(?, ?)') + DbTools::prepareListString($valueCount, '(?, ?)') )); $args = 0; diff --git a/src/Profile/ProfileFields.php b/src/Profile/ProfileFields.php index 3269255..6cc28d1 100644 --- a/src/Profile/ProfileFields.php +++ b/src/Profile/ProfileFields.php @@ -3,6 +3,7 @@ namespace Misuzu\Profile; use InvalidArgumentException; use RuntimeException; +use Index\Data\DbTools; use Index\Data\IDbConnection; use Index\Data\IDbResult; use Misuzu\DbStatementCache; @@ -22,7 +23,7 @@ class ProfileFields { $query = 'SELECT field_id, field_order, field_key, field_title, field_regex FROM msz_profile_fields'; if($hasFieldValueInfos) - $query .= sprintf(' WHERE field_id IN (%s)', msz_where_in_list($fieldValueInfos)); + $query .= sprintf(' WHERE field_id IN (%s)', DbTools::prepareListString($fieldValueInfos)); $query .= ' ORDER BY field_order ASC'; $stmt = $this->cache->get($query); @@ -74,12 +75,12 @@ class ProfileFields { if($hasFieldInfos) { ++$args; - $query .= sprintf(' WHERE field_id IN (%s)', msz_where_in_list($fieldInfos)); + $query .= sprintf(' WHERE field_id IN (%s)', DbTools::prepareListString($fieldInfos)); } if($hasFieldValueInfos) $query .= sprintf(' %s format_id IN (%s)', (++$args > 1 ? 'AND' : 'WHERE'), - msz_where_in_list($fieldValueInfos) + DbTools::prepareListString($fieldValueInfos) ); $stmt = $this->cache->get($query); @@ -226,7 +227,7 @@ class ProfileFields { $args = 0; $stmt = $this->cache->get( 'REPLACE INTO msz_profile_fields_values (field_id, user_id, format_id, field_value) VALUES ' - . msz_where_in_list($rows, '(?, ?, ?, ?)') + . DbTools::prepareListString($rows, '(?, ?, ?, ?)') ); foreach($rows as $row) { @@ -261,7 +262,7 @@ class ProfileFields { $args = 0; $stmt = $this->cache->get(sprintf( 'DELETE FROM msz_profile_fields_values WHERE user_id = ? AND field_id IN (%s)', - msz_where_in_list($fieldInfos) + DbTools::prepareListString($fieldInfos) )); $stmt->addParameter(++$args, $userInfo); foreach($fieldInfos as $value) diff --git a/utility.php b/utility.php index 902692f..fd81987 100644 --- a/utility.php +++ b/utility.php @@ -1,12 +1,6 @@