mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
CSV importer: boolean and ap variants/typos
- add AP aliases for: - Design & politique du multiple → DPM, - Pratiques artistiques & complexité scientifique → PACS, - Narraion Speculative typo → NS - Fix: OUI/NON CSV artefacts in contact_interne — clean DB, guard in findOrCreateAuthor and CSV import - Cleaned 141 authors.email = 'NON' rows → NULL in dev DB - findOrCreateAuthor: treat OUI/NON as null (CSV boolean artefact in email column) - CSV import: sanitize contact column — OUI/NON → empty string before passing to findOrCreateAuthor
This commit is contained in:
@@ -744,11 +744,11 @@ class Database
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all languages
|
||||
* Get all languages (name is capitalized for display).
|
||||
*/
|
||||
public function getAllLanguages(): array
|
||||
{
|
||||
$stmt = $this->pdo->query('SELECT * FROM languages ORDER BY name');
|
||||
$stmt = $this->pdo->query("SELECT id, UPPER(SUBSTR(name,1,1)) || SUBSTR(name,2) as name, created_at FROM languages ORDER BY name");
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
@@ -954,6 +954,11 @@ class Database
|
||||
*/
|
||||
public function findOrCreateAuthor($name, $email = null, bool $showContact = false)
|
||||
{
|
||||
// Normalise CSV artefacts: OUI/NON strings in email column → null
|
||||
if ($email !== null && in_array(strtoupper(trim($email)), ['NON', 'OUI'], true)) {
|
||||
$email = null;
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT id FROM authors WHERE name = ?');
|
||||
$stmt->execute([$name]);
|
||||
$author = $stmt->fetch();
|
||||
@@ -1522,11 +1527,11 @@ class Database
|
||||
|
||||
/**
|
||||
* Return the ID of an existing language by name, inserting it if absent.
|
||||
* Name is trimmed and stored as-is (case-preserved).
|
||||
* Name is stored lowercase and displayed with first letter capitalized.
|
||||
*/
|
||||
public function getOrCreateLanguage(string $name): int
|
||||
{
|
||||
$name = trim($name);
|
||||
$name = strtolower(trim($name));
|
||||
$stmt = $this->pdo->prepare('SELECT id FROM languages WHERE LOWER(name) = LOWER(?) LIMIT 1');
|
||||
$stmt->execute([$name]);
|
||||
$id = $stmt->fetchColumn();
|
||||
|
||||
Reference in New Issue
Block a user