ldo...@users.adullact.net
unread,Feb 25, 2026, 8:33:27 AM (8 days ago) Feb 25Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openmairie...@googlegroups.com
Author: ldorner
Date: 2026-02-25 14:33:24 +0100 (Wed, 25 Feb 2026)
New Revision: 5490
Modified:
openmairie_exemple/branches/4.11.0-compatibilite-php8.1_WIP3/core/om_application_pdo.trait.php
Log:
fix: detection des colonnes bool via build_query_columns_metadata_map
Modified: openmairie_exemple/branches/4.11.0-compatibilite-php8.1_WIP3/core/om_application_pdo.trait.php
===================================================================
--- openmairie_exemple/branches/4.11.0-compatibilite-php8.1_WIP3/core/om_application_pdo.trait.php 2026-02-25 11:35:03 UTC (rev 5489)
+++ openmairie_exemple/branches/4.11.0-compatibilite-php8.1_WIP3/core/om_application_pdo.trait.php 2026-02-25 13:33:24 UTC (rev 5490)
@@ -518,6 +518,33 @@
*/
}
+ protected function build_query_columns_metadata_map($query) {
+ $map = array();
+ if (preg_match_all('/(?:FROM|JOIN)\s+(?:[\w]+\.)?(\w+)/i', $query, $matches)) {
+ foreach (array_unique($matches[1]) as $table_name) {
+ $class_name = $this->resolve_class_name_from_table($table_name);
+ if ($class_name === null) {
+ continue;
+ }
+ if (method_exists($class_name, 'get_columns_metadata')) {
+ foreach ($class_name::get_columns_metadata() as $col_name => $col_info) {
+ $map[strtolower($col_name)] = $col_info;
+ }
+ }
+ $inst = $this->get_inst__om_dbform(array(
+ 'obj' => $table_name,
+ 'idx' => 0,
+ ));
+ if ($inst !== null && method_exists($inst, 'get_additional_columns')) {
+ foreach ($inst->get_additional_columns() as $col_name => $col_info) {
+ $map[strtolower($col_name)] = $col_info;
+ }
+ }
+ }
+ }
+ return $map;
+ }
+
/**
* Récupère la référence à la connexion PDO.
*
@@ -1452,21 +1479,29 @@
if (!$get_columns_name && ($value === true || $value === false)) {
$boolean_columns[$key] = true;
} else if (!$get_columns_name && ($value === 1 || $value === "1" || $value === "t" || $value === 0 || $value === "0" || $value === "f" || $value == "")) {
- $meta = $stmt->getColumnMeta($i);
- $column_name = strtolower($meta['name']);
- $native_type = isset($meta['native_type']) ? $meta['native_type'] : '';
- /*$columns_meta[] = array(
- 'name' => $column_name,
- 'table' => isset($meta['table']) ? $meta['table'] : '',
- 'type' => $native_type,
- 'len' => isset($meta['len']) ? $meta['len'] : 0,
- 'flags' => isset($meta['flags']) ? $meta['flags'] : array(),
- );*/
- // Mémoriser les colonnes booléennes pour la normalisation
- if ($native_type === 'bool') {
- $boolean_columns[$column_name] = true;
- $boolean_columns[$i] = true;
- }
+ // Construire la map des métadonnées une seule fois
+ // à partir des tables de la requête (get_columns_metadata
+ // + get_additional_columns), évite getColumnMeta()
+ if (!isset($query_metadata_map)) {
+ $query_metadata_map = $this->build_query_columns_metadata_map($query);
+ }
+ $lower_key_check = strtolower($key);
+ if (isset($query_metadata_map[$lower_key_check])) {
+ if ($query_metadata_map[$lower_key_check]['type'] === 'bool') {
+ $boolean_columns[$lower_key_check] = true;
+ $boolean_columns[$i] = true;
+ }
+ } else {
+ // Fallback : getColumnMeta() pour les colonnes
+ // non trouvées dans les métadonnées des classes
+ $meta = $stmt->getColumnMeta($i);
+ $column_name = strtolower($meta['name']);
+ $native_type = isset($meta['native_type']) ? $meta['native_type'] : '';
+ if ($native_type === 'bool') {
+ $boolean_columns[$column_name] = true;
+ $boolean_columns[$i] = true;
+ }
+ }
}
$i++;