Overview
Comment:Optimisation : index sur les champs listés
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2dac7f9addf0997e1e9d5ff01ba820788c056410
User & Date: bohwaz on 2014-04-22 00:27:06
Other Links: manifest | tags
Context
2014-04-22
00:32
Petites améliorations expérience sur mobile check-in: 70a64c37ce user: bohwaz tags: trunk
00:27
Optimisation : index sur les champs listés check-in: 2dac7f9add user: bohwaz tags: trunk
2014-04-21
15:59
le nom du fichier est en français check-in: d88988316b user: bohwaz tags: trunk
Changes

Modified src/include/class.champs_membres.php from [53bbc4800d] to [64b68e48e3].

439
440
441
442
443
444
445
446
447
448
449













450
451
452
453
454
455
456
457
458
459
460
        if ($config->get('champ_identifiant'))
        {
            // Mettre les champs identifiant vides à NULL pour pouvoir créer un index unique
            $db->exec('UPDATE membres SET '.$config->get('champ_identifiant').' = NULL 
                WHERE '.$config->get('champ_identifiant').' = "";');

            // Création de l'index unique
            $db->exec('DROP INDEX IF EXISTS membres_identifiant;');
            $db->exec('CREATE UNIQUE INDEX membres_identifiant ON membres ('.$config->get('champ_identifiant').');');
        }
        













    	$db->exec('END;');
    	$db->exec('PRAGMA foreign_keys = ON;');

    	$config->set('champs_membres', $this);
    	$config->save();

    	return true;
    }
}

?>







<


|
>
>
>
>
>
>
>
>
>
>
>
>
>









<
<
439
440
441
442
443
444
445

446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470


        if ($config->get('champ_identifiant'))
        {
            // Mettre les champs identifiant vides à NULL pour pouvoir créer un index unique
            $db->exec('UPDATE membres SET '.$config->get('champ_identifiant').' = NULL 
                WHERE '.$config->get('champ_identifiant').' = "";');

            // Création de l'index unique

            $db->exec('CREATE UNIQUE INDEX membres_identifiant ON membres ('.$config->get('champ_identifiant').');');
        }

        // Création des index pour les champs affichés dans la liste des membres
        $listed_fields = array_keys($this->getListedFields());
        foreach ($listed_fields as $field)
        {
            if ($field === $config->get('champ_identifiant'))
            {
                // Il y a déjà un index
                continue;
            }

            $db->exec('CREATE INDEX membres_liste_' . $field . ' ON membres (' . $field . ');');
        }

    	$db->exec('END;');
    	$db->exec('PRAGMA foreign_keys = ON;');

    	$config->set('champs_membres', $this);
    	$config->save();

    	return true;
    }
}


Modified src/include/class.membres.php from [7f657564b8] to [5f240c7db4].

637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
        if (!in_array('email', $fields))
        {
            $fields []= 'email';
        }

        $fields = implode(', ', $fields);

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, '.$fields.', '.$config->get('champ_identite').' AS identite,
                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres '.$where.'
                ORDER BY '.$order.' LIMIT ?, ?;',
            SQLITE3_ASSOC,
            $begin,
            self::ITEMS_PER_PAGE
        );
    }

    public function countByCategory($cat = 0)
    {
        $db = DB::getInstance();

        if (is_int($cat) && $cat)







<
|
|
|
|
|
<
|
<







637
638
639
640
641
642
643

644
645
646
647
648

649

650
651
652
653
654
655
656
        if (!in_array('email', $fields))
        {
            $fields []= 'email';
        }

        $fields = implode(', ', $fields);


        $query = 'SELECT id, id_categorie, '.$fields.', '.$config->get('champ_identite').' AS identite,
            strftime(\'%s\', date_inscription) AS date_inscription
            FROM membres '.$where.'
            ORDER BY '.$order.' LIMIT ?, ?;';


        return $db->simpleStatementFetch($query, SQLITE3_ASSOC, $begin, self::ITEMS_PER_PAGE);

    }

    public function countByCategory($cat = 0)
    {
        $db = DB::getInstance();

        if (is_int($cat) && $cat)