-recherche des tags de l’image du mois (PDO)
-affichage des tags sous l’image, avec liens vers Zenphoto
This commit is contained in:
2019-01-06 11:06:25 +01:00
parent 8b6452fa28
commit 904e6ac59b
3 changed files with 76 additions and 24 deletions

View File

@@ -212,9 +212,6 @@ function imagesFromZPAlbum ($album, $connexion) {
/*
Ajouter: EXIFLensInfo
Array
(
[0] => Array
@@ -226,6 +223,7 @@ function imagesFromZPAlbum ($album, $connexion) {
[EXIFFNumber] => f/7,1
[EXIFISOSpeedRatings] => 500
[EXIFFocalLength] => 700 mm
[EXIFLensInfo] => EF500mm f/4L IS USM
[EXIFGPSLatitude] =>
[EXIFGPSLatitudeRef] =>
[EXIFGPSLongitude] =>
@@ -244,6 +242,68 @@ function imagesFromZPAlbum ($album, $connexion) {
return $fichier;
}
function ZPGetTag ($filename, $album, $connexion) {
$table = array();
$table['images'] = $connexion['zp_prefix'] . "images";
$table['albums'] = $connexion['zp_prefix'] . "albums";
$table['obj_to_tag'] = $connexion['zp_prefix'] . "obj_to_tag";
$table['tags'] = $connexion['zp_prefix'] . "tags";
$charset = 'utf8';
$host = $connexion['host'];
$dbname = $connexion['db_zenphoto'];
$dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $connexion['user'], $connexion['password'], $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
// 1. id de l'image:
$query1 = "SELECT `id` FROM `" . $table['images'] . "` WHERE `filename` = ?";
$stmt = $pdo->prepare($query1);
$stmt->execute([$filename]);
//$fichier = $stmt->fetchAll(PDO::FETCH_ASSOC);
while ($row = $stmt->fetch()) {
//echo $row['id'] . "\n";
$id_image = $row['id'];
}
// 2. ids des tags de l'image:
$query2 = "SELECT `tagid` FROM `" . $table['obj_to_tag'] . "` WHERE `objectid` = ?";
$stmt = $pdo->prepare($query2);
$stmt->execute([$id_image]);
//$ids_tag = $stmt->fetchAll(PDO::FETCH_COLUMN);
while ($ids_tag = $stmt->fetch()) {
$query_tags .= " `id` = " . $ids_tag['tagid'] . " OR ";
}
// 3. Liste des tags correspondant aux ids:
$query_tags = substr($query_tags, 0, -4);;
$query3 = "SELECT `name` FROM `_tags` WHERE $query_tags";
$stmt = $pdo->prepare($query3);
$stmt->execute();
$tags = $stmt->fetchAll(PDO::FETCH_COLUMN);
return $tags;
}
/*
page-ce-mois-ci.php
*/