<?php
namespace TheatreCore\Repository;
use TheatreCore\Entity\Aidecontacts;
use TheatreCore\Entity\Aides;
use TheatreCore\Traits\TheatreTrait;
use TheatreCore\Entity\Contacts;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\ORM\Query;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* AidesRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class AidesRepository extends ServiceEntityRepository
{
use TheatreTrait;
private $em;
public $__table;
public $__table_object;
public $__idtable;
public function __construct(ManagerRegistry $registry, TranslatorInterface $translator)
{
parent::__construct($registry, Aides::class);
$this->__table = $this->getClassMetadata()->getTableName();
$this->__table_object = $this->getClassMetadata()->name;
$this->__idtable = $this->getClassMetadata()->getSingleIdentifierFieldName();
$this->translator = $translator;
}
// {{{ findData()
/** Recherche d'aide
*
* Permet de rechercher des aides selon différents critères
*
* @access public
* @see Theatre::find()
*/
public function findData($idclassification = null)
{
$query = $this->createQueryBuilder('e');
if ($this->getCount()) {
$query->select('COUNT(e.idaide)');
$this->setCount(false);
return $query;
}
//
// // parametres
// if(isset($_REQUEST['keywords']) && $_REQUEST['keywords']!='nom') {
// $keywords = filter_var(trim($_REQUEST['keywords']));
// }
// if(isset($_REQUEST['idaide']) && my_is_int($_REQUEST['idaide'])) {
// $idaide = (int)$_REQUEST['idaide'];
// }
//
// // query perso
// $query = 'SELECT '.$this->__table.'.* FROM '.$this->__table.'
// LEFT JOIN aidecontacts ON aidecontacts.idaidecontact = aides.idaidecontact
// LEFT JOIN contacts ON contacts.idcontact = aides.idcontact
// WHERE 1';
//
// //recherche stricte par id
// if(!empty($idaide)) {
// $query .= ' AND cl.idaide='.(int)$idaide;
// } else {
// // mots cles
// if (!empty($keywords)) {
// $query .= ' AND (aide LIKE \'%'.$this->escape($keywords).'%\' OR aidecontacts.title LIKE \'%'.$this->escape($keywords).'%\' OR contacts.organisation LIKE \'%'.$this->escape($keywords).'%\') ';
// }
// }
// on lance la recherche
return $query->getQuery();
}
// }}}
// {{{ setToArray()
/** Liste des aides dans un tableau associatif
*
* Tableau associatif notament utilisé pour lister les informations sur des aides
* Utile pour générer les tableaux HTML de listes de aides
*
* @access public
* @return array
* @see findData()
*/
public function setToArray($spec = true)
{
if ($spec == true) {
$this->findData();
}
$values = array();
$color = null;
$nb = 0;
while ($this->fetch()) {
$values[$nb] = $this->getInfosAide(null, array('get_contact' => true, 'get_aidecontact' => true));
$values[$nb]['id'] = $this->idaide;
// couleur de ligne alternative
$color = $this->colorAlternate($color);
$values[$nb]['colorline'] = $color;
$nb++;
}
return $values;
}
// }}}
// {{{ getInfosAide()
/** Informations sur une aide
*
* @access public
* @param int $idaide Identifiant de l'aide
* @return array
*/
public function getInfosAide($idaide = null, $params = array())
{
$infos = array();
////////////// infos de la table
if (empty($this->idaide) || $idaide) {
$infos = $this->createQueryBuilder('u')
->select('u, ac, uc')
->leftJoin('u.idaidecontact', 'ac')
->leftJoin('u.idcontact', 'uc')
->where('u.' . $this->__idtable . ' =:value')->setParameter('value', $idaide)
->getQuery()
->getOneOrNullResult(Query::HYDRATE_ARRAY);
$this->loadResult($infos);
}
$infos += array(
'idaide' => $this->idaide,
'idcontact' => $this->idcontact,
'type_aide' => $this->typeAide,
'idaidecontact' => $this->idaidecontact,
'aide' => $this->aide,
'description' => $this->description,
'url_clean' => $this->urlClean,
'dateupdate' => $this->dateupdate,
'dateinsert' => $this->dateinsert,
'publish' => $this->publish,
);
if (!empty($infos['typeAide'])) {
$infos['type_aide_label'] = $this->getAideTypes($infos['typeAide']);
$infos['type_aide_infos'] = $this->getAideTypes($infos['typeAide'], false);
} else {
$infos['type_aide_label'] = null;
}
$mentions = array(
'Spectacles' => 'le spectacle',
'Texts' => 'le texte',
'Contacts' => 'la structure',
'Persons' => 'la biographie',
);
foreach ($mentions as $f => $v) {
$infos['mention_' . $f] = $this->{'mention' . ucfirst($f)};
}
$con = $this->getEntityManager();
// récupère les infos sur le contact
if (!empty($params['get_contact']) && $infos['idcontact'] != '') {
$infos['contact'] = $con->getRepository(Contacts::class)->getInfosContact($infos['idcontact'], array('get_profile_picture' => true));
}
// récupère les infos sur la catégorie
if (!empty($params['get_aidecontact']) && !empty($infos['idaidecontact'])) {
$infos['aidecontact'] = $con->getRepository(Aidecontacts::class)->getInfosAidecontact($infos['idaidecontact']['idaidecontact']);
}
$infos['nameview'] = $infos['aide'];
return $infos;
}
// }}}
// {{{ getObjectTitle()
/** Infos de l'item recherché
*
*
* @access public
* @param int $idobject Identifiant de l'item
* @param array $infos_object Informations pour construire le titre
* @param array $params Paramétres supplémentaires
* @return string|array
*/
public function getObjectTitle($idobject = null, $infos_object = array(), $params = array())
{
if (!$idobject && isset($this->idaide)) $idobject = $this->idaide;
// champs
$fields = array('idaide', 'aide', 'url_clean');
if (!empty($infos_object)) {
foreach ($fields as $k => $v) {
if (array_key_exists($v, $infos_object)) {
$infos[$v] = $infos_object[$v];
} else {
$infos[$v] = '';
}
}
} else {
//charger les infos que si necessaire
if (empty($this->aide)) {
$sql = 'SELECT ' . implode(',', $fields) . '
FROM ' . $this->__table . '
WHERE ' . $this->__idtable . '=' . $idobject;
$infos = $this->queryRow($sql);
} else {
foreach ($fields as $k => $v) {
if (isset($this->$v) && $this->$v != '') {
$infos[$v] = trim($this->$v);
} else {
$infos[$v] = '';
}
}
}
}
$infos = $this->getInfosAide($idobject, array(
'get_contact' => true,
'get_aidecontact' => true,
));
// catégorie
if (!empty($infos['aidecontact'])) {
$title[] = $infos['aidecontact']['title'];
}
$title[] = $infos['aide'];
if (!empty($infos['type_aide_label'])) {
$title[] = $infos['type_aide_label'];
}
// contact
if (!empty($infos['contact'])) {
$title[] = $infos['contact']['organisation'];
}
$infos['title'] = join(' / ', $title);
// renvoyer un array plutôt que le titre (utile si on veux l'url)
if (array_key_exists('return_array', $params)) {
return $infos;
}
return $infos['title'];
}
// }}}
// {{{ getRelationsArray()
/** Décrit les relations de l'objet
*
* @access public
* @param string|int $type si on souhaite retourner uniquement un type precis
* @see Theatre::getLinkedObject()
*/
public function getRelationsArray($type)
{
$array_types = array(
'idcontact' => array(// contacts associés ?
'type_join' => 'simple',
'dest_table' => 'contacts',
'fields' => array('idcontact', 'organisation', 'lastname', 'firstname', 'type', 'url_clean', 'valid'),
'join_field_src' => 'idcontact',
'description' => 'Contact associé à l\'aide',
'silent_delete_relation' => true,
),
'text_aide' => array(// text associés ?
'type_join' => 'multiple',
'dest_table' => 'texts',
'fields' => array('idtext', 'title', 'publish', 'url_clean', 'valid'),
'join_table' => 'text_aide',
'description' => 'Textes associé à l\'aide',
'silent_delete_relation' => true,
),
);
// retourne uniquement un type précis
if ($type == 'all') {
return $array_types;
}
if (!empty($array_types[$type])) {
$array_types[$type]['type'] = $type;
return $array_types[$type];
} else {
return null;
}
}
// }}}
// {{{ getListSearch()
/** Liste des aides
*
* Pour les champs Ajax de relations et les recherches diverses
*
* @access public
* @param string $lettres Pour la recherche alphabetique
* @param string $type Pour le type recherche (editeurs, revues...)
* @param string $keywords Recherche par mots cles
* @return array
*/
public function getListSearch($lettre, $type = null, $keywords = null)
{
$sql = 'SELECT a.idaide, a.aide, a.type_aide, c.organisation, ac.title
FROM ' . $this->__table . ' a
JOIN contacts c ON c.idcontact=a.idcontact
LEFT JOIN aidecontacts ac ON a.idaidecontact=ac.idaidecontact
WHERE 1 ';
// selection par ordre alpha
if (!empty($lettre) && $lettre != 'tous') {
$sql_where[] = array('LOWER(LEFT(LTRIM(aide),1))=\'' . $this->escape($lettre) . '\'');
}
// recherche avec un mot cle
$list = $this->splitKeywords($keywords);
if ($list) {
if (!empty($list[$this->IDSTR])) {
// mots clés
foreach ($list[$this->IDSTR] as $s) {
$sql_more_name[] = 'aide LIKE \'%' . $s . '%\'';
}
$sql_where[] = array('(' . join(' OR ', $sql_more_name) . ')');
}
if (!empty($list[$this->IDNUM])) {
// recherche par numéro d'id pour les mots clés numériques
$sql_where[] = array('idaide IN (' . implode(',', $list[$this->IDNUM]) . ')', 'OR');
}
}
if (!empty($sql_where)) {
foreach ($sql_where as $k => $v) {
if (!empty($v[1])) {
$sql .= ' ' . $v[1] . ' ' . $v[0];
} else {
$sql .= ' AND ' . $v[0];
}
}
}
$sql .= ' ORDER BY title';
$this->query($sql);
$r = array();
while ($this->fetch()) {
$infos = array();
foreach (array('title', 'aide', 'type_aide', 'organisation') as $f) {
if (!empty($this->$f)) {
if ($f == 'type_aide') {
$infos[$f] = $this->getAideTypes($this->$f);
} else {
$infos[] = $this->$f;
}
}
}
$r[$this->idaide] = join(' / ', $infos);
// si trouvé par id, on l'affiche en fin de titre
if (!empty($list[$this->IDNUM]) && in_array($this->idaide, $list[$this->IDNUM])) {
$r[$this->idaide] .= ' - n°' . $this->idaide;
}
}
$this->free();
return $r;
}
// }}}
// {{{ getListAides()
/** Retourne des listes des aides
*
* Retourne des listes de aides au format "standard""
*
* @access public
* @param array $params_sql paramètre pour la requete SQL
* @param array $format_vignette de la vignette si pas standard
* @param array $params_display paramètre pour l'affichage
* @return array
*/
public function getListAides($params_sql = null, $format_vignette = array(), $params_display = array())
{
$conn = $this->getEntityManager();
// si pas de tableau
if (!isset($params_sql['special'])) {
$params_sql['special'] = array();
}
if (!isset($params_sql['params'])) {
$params_sql['params'] = array();
}
// construction de la requête avec le passage de paramètres
$sql = $this->getSQLAides($params_sql);
// vignettes
if (empty($params['format_vignette'])) {
$format_vignette = array('width' => 130, 'height' => 110, 'direction' => 'thumb');
}
// paramètre de debug
$dbg = (empty($params_sql['dbg'])) ? array() : $dbg = $params_sql['dbg'];
// executer la requete
$this->query($sql, $dbg);
$videos = array();
// donnée entières ?
if (empty($params_display['alldata'])) {
$params_display['alldata'] = false;
}
// debug
$start_boucle = microtime(true);
$aides = array();
// on boucle
while ($this->fetch()) {
$idaide = $this->idaide;
if (!empty($params_sql['fields'])) {
foreach ($params_sql['fields'] as $f) {
$aides[$idaide][$f] = $this->$f;
}
} else {
$aides[$idaide] = $this->getInfosAide($idaide, array('get_contact' => true, 'get_aidecontact' => true));
$aides[$idaide]['description_courte'] = $this->cutSentence(strip_tags($aides[$idaide]['description']), 45, true);
}
}
// debug de la boucle
if ($this->isTraceMode('list_object')) {
$this->setTraceInfos(array(
'execution_time_boucle' => microtime(true) - $start_boucle,
'nb_occurence' => count($aides),
'dbg' => $dbg,
));
}
$this->free();
// grouper par contact
if (!empty($params_display['group_by_contact']) && !empty($aides)) {
foreach ($aides as $k => $v) {
$aides_by_contact[$v['contact']['idcontact']] = $v['contact'];
$aides_by_contact[$v['contact']['idcontact']]['profile_picture'] = $conn->getRepository(Contacts::class)->getVignetteContact($v['contact']['idcontact'], array(), 'class_pp');
if (strpos($aides_by_contact[$v['contact']['idcontact']]['profile_picture'], 'normal-def.jpg') !== false) {
$aides_by_contact[$v['contact']['idcontact']]['profile_picture'] = $_ENV['URL_THNET'] . '/images/menu/interface/no_contact-100x100.png';
}
}
return $aides_by_contact;
}
// grouper par type d'aides
if (!empty($params_display['groupe_by_type']) && !empty($aides)) {
foreach ($aides as $k => $v) {
if (empty($aides_by_type[$this->getAideTypes($v['type_aide'], false, true)]['type_aide'])) {
$aides_by_type[$this->getAideTypes($v['type_aide'], false, true)] = array(
'type_aide' => $v['type_aide'],
'type_aide_label' => $this->getAideTypes($v['type_aide'], true, false),
);
}
$aides_by_type[$this->getAideTypes($v['type_aide'], false, true)]['datas'][$v['idaide']] = $v;
}
return $aides_by_type;
}
return $aides;
}
// }}}
// {{{ countListAides()
/** Compter la liste des aides
*
* @access public
* @param array $params_sql paramètre pour la requete SQL
* @param bool $debug mode débugage
* @return int
*/
public function countListAides($params_sql = null, $debug = false)
{
// si pas de limite => tout
if (empty($params_sql['limit'])) {
$params_sql['limit'] = array('all');
}
$params_sql['special']['count_only'] = true;
// construction de la requête avec le passage de paramètres
return $this->queryOne($this->getSQLAides($params_sql, $debug));
}
// }}}
// {{{ getSQLAides()
/** Générer la requete standard pour des aides
*
* @access public
* @param array $aueru Les paramètres pour la requete
* @param bool $debug afficher la requête
* @return string
*/
public function getSQLAides($query = array(), $debug = false)
{
// on prepare les tableaux
foreach (array('select', 'from', 'where', 'order', 'group', 'limit') as $t) {
if (!empty($query[$t])) {
if (!is_array($query[$t])) {
$query[$t][] = $query[$t];
} else {
$query[$t] = $query[$t];
}
} else {
$query[$t] = array();
}
}
// champs par défaut
$this->addSQLParams('select', $query, array(
array('aides' => '*')
));
$this->addSQLParams('from', $query, array(
'contacts',
));
$this->addSQLParams('join', $query, array(
'aides.`idcontact`' => 'contacts.`idcontact`',
));
// publié ou pas
if (empty($query['publish']) && $_ENV['CHECK_IF_ONLINE']) {
$this->addSQLParams('where', $query, array(
array('aides', 'publish', 1)
));
} elseif (!empty($query['publish'])) {
$this->addSQLParams('where', $query, array(
array('aides', 'publish', $query['publish'])
));
}
// recherche par liaison via text_aide
if (!empty($query['special']['idtexts']) || !empty($query['special']['text_aide'])) {
$this->addSQLParams('from', $query, array(
'text_aide',
));
// jointure entre les 3 tables
$this->addSQLParams('join', $query, array(
'aides.`idaide`' => 'text_aide.`idaide`',
));
}
if (!empty($query['special']['idtexts'])) {
if (is_array($query['special']['idtexts'])) {
$this->addSQLParams('where', $query, array(
array('text_aide', 'idtext', $query['special']['idtexts']),
));
} else {
$this->addSQLParams('group', $query, 'no');
$this->addSQLParams('distinct', $query, 'no');
$this->addSQLParams('select', $query, array(
array('text_aide' => '*')
));
}
}
// recherche des aides d'un contact
if (!empty($query['special']['aides']['idcontacts'])) {
$this->addSQLParams('where', $query, array(
array('aides', 'idcontact', $query['special']['aides']['idcontacts']),
));
}
// recherche par type
if (!empty($query['special']['type_aides'])) {
$query['special']['type_aide'] = $query['special']['type_aides'];
}
if (!empty($query['special']['type_aide'])) {
$this->addSQLParams('where', $query, array(
array('aides', 'type_aide', $query['special']['type_aide']),
));
}
// recherche par type
if (!empty($query['special']['idaidecontact'])) {
$this->addSQLParams('where', $query, array(
array('aides', 'idaidecontact', $query['special']['idaidecontact']),
));
}
// si object => liaison
if (!empty($query['special']['contact_aide']) || !empty($query['special']['idcontacts'])) {
$this->addSQLParams('from', $query, array(
'contact_aide',
));
// jointure entre les 3 tables
$this->addSQLParams('join', $query, array(
'aides.`idaide`' => 'contact_aide.`idaide`',
));
}
// recherche par liaison via contact_aide
if (!empty($query['special']['idcontacts'])) {
$this->addSQLParams('where', $query, array(
array('contact_aide', 'idcontact', $query['special']['idcontacts']),
));
}
// si object => liaison
if (!empty($query['special']['spectacle_aide']) || !empty($query['special']['idspectacles'])) {
$this->addSQLParams('from', $query, array(
'spectacle_aide',
));
// jointure entre les 3 tables
$this->addSQLParams('join', $query, array(
'aides.`idaide`' => 'spectacle_aide.`idaide`',
));
}
// recherche par liaison via _aide
if (!empty($query['special']['idspectacles'])) {
$this->addSQLParams('where', $query, array(
array('spectacle_aide', 'idspectacle', $query['special']['idspectacles']),
));
}
return $this->getSQLObject($query);
}
// }}}
// {{{ countAides()
/** Compter la liste des aides nominations ou laureats
*
* @access public
* @param array $params_sql paramètre pour la requete SQL
* @param bool $debug mode débugage
* @return int
*/
public function countAides($params_sql = null, $debug = false)
{
$nb = 0;
foreach (array('spectacle', 'text', 'person', 'contact') as $t) {
$sql = 'SELECT COUNT(' . $t . '_aide.`idaide`)
FROM aides
JOIN ' . $t . '_aide ON ' . $t . '_aide.`idaide`=aides.`idaide`
WHERE aides.`idcontact`=' . (int)$params_sql['special']['aides']['idcontacts'] . '
AND aides.`type_aide`=' . (int)$params_sql['special']['type_aide'] . ' ';
$nb = $nb + $this->queryOne($sql);
}
return $nb;
}
// }}}
// {{{ getAides()
/** Retourne des listes des aides
*
* Retourne des listes de aides au format "standard""
*
* @access public
* @return array
*/
public function getAides()
{
$sql = 'SELECT idaide,aide
FROM ' . $this->__table . ' WHERE 1 ';
return $this->queryAll($sql, array(), null, true);
}
// }}}
// {{{ getAideTypes()
/** Retourne des listes des types
*
* Retourne des listes de type d'aide'
*
* @access public
* @return array
*/
public function getAideTypes($type_aide = null, $label = true, $name = false, $params = array())
{
$types_aide = array(
1 => array(
'label' => 'Aide/soutien',
'contact_link' => '',
'name' => 'aides',
),
2 => array(
'label' => 'Lauréat',
'contact_link' => 'laureats',
'name' => 'prix',
),
3 => array(
'label' => 'Nomination',
'contact_link' => 'nominations',
'name' => 'nomination',
),
4 => array(
'label' => 'Sélection',
'contact_link' => 'selections',
'name' => 'selection',
)
);
if ($label) {
foreach ($types_aide as $k => $v) {
$types_aide_label[$k] = $v['label'];
}
$types_aide = $types_aide_label;
}
if ($name) {
foreach ($types_aide as $k => $v) {
$types_aide_label[$k] = $v['name'];
}
$types_aide = $types_aide_label;
}
if (!empty($type_aide)) {
if (isset($types_aide[$type_aide])) {
return $types_aide[$type_aide];
} else {
return null;
}
}
return $types_aide;
}
// }}}
// {{{ getAidesByYearContact()
/** Récupérer les derniers laureats
*
*
* @access public
* @return array
*/
public function getAidesByYearContact($idcontact, $periode = 'current', $type_aide = 0, $params_display = array())
{
$types_object = array(
'text' => array('name' => 'Les textes'),
'spectacle' => array('name' => 'Les spectacles'),
'person' => array('name' => 'Les artistes'),
);
$aides['nb_laureats'] = 0;
$conn = $this->getEntityManager();
foreach ($types_object as $t => $v) {
// récupèrer les prix associés au contact
$object_aide = $conn->getRepository('TheatreCore\Entity\\' . ucfirst($t) . 'Aide');
// si current, trouver l'année de l'aide la plus proche
if ($periode == 'current') {
$params_sql_year_aide = array(
'special' => array(
'aides' => array(
'idcontacts' => $idcontact,
'type_aides' => array($type_aide), // Prix
),
),
'limit' => array(0, 1),
'dbg' => array($t . '_year_aide', 'Année la plus proche de ' . $t . ' lauréats'),
);
$years = $object_aide->{'getList' . ucfirst($t) . 'Aide'}($params_sql_year_aide);
foreach ($years as $year) {
$periode = $year['year_start'];
break;
}
}
$params_sql_aide = array(
'special' => array(
'aides' => array(
'idcontacts' => $idcontact,
'type_aides' => array($type_aide), // Prix
),
),
'dbg' => array($t . '_aide', 'Nombre de ' . $t . ' lauréats'),
);
// compter le nombre total de lauréats
$nb_list = $object_aide->{'countList' . ucfirst($t) . 'Aide'}($params_sql_aide);
// trouver les nominations de cette année
$params_sql_aide['special']['period']['year'] = $periode;
$aides[$t] = $object_aide->{'getList' . ucfirst($t) . 'Aide'}($params_sql_aide, $params_display);
$aides['year'] = $periode;
$aides['nb_laureats'] = count($aides[$t]) + $aides['nb_laureats'];
}
return $aides;
}
// }}}
// {{{ countTextAuthors()
/** Compter les auteurs ayant reçus une aide pour leurs texts
*
*
* @access public
* @return array
*/
public function countTextAuthors($idaidecontact = null)
{
$sql = 'SELECT COUNT(DISTINCT(ta.`idperson`)) as total
FROM text_aide tai JOIN aides ai
ON ai.`idaide`=tai.`idaide`JOIN text_author ta
ON ta.`idtext`=tai.`idtext`
WHERE ai.`idaidecontact`=' . $idaidecontact;
$res = $this->queryOne($sql);
if ($res) {
return $res;
} else {
return 0;
}
}
// }}}
// {{{ countTexts()
/** Compter les texts qui ont reçus une aide
*
*
* @access public
* @return array
*/
public function countTexts($idaidecontact = null)
{
$sql = 'SELECT COUNT(DISTINCT(tai.`idtext`))
FROM text_aide tai JOIN aides ai
ON ai.`idaide`=tai.`idaide`
WHERE ai.`idaidecontact`=' . $idaidecontact;
$res = $this->queryOne($sql);
if ($res) {
return $res;
} else {
return 0;
}
}
// }}}
// {{{ getAuthorsTexts()
/** trouver les auteurs ayant reçus une aide pour leurs texts
*
*
* @access public
* @return array
*/
public function getAuthorsTexts($idaidecontact = null)
{
$sql = 'SELECT p.`idperson`,p.`lastname`,p.`firstname`,p.`url_clean`, LEFT(p.`lastname`, 1) AS letter
FROM text_aide tai
JOIN aides ai ON ai.`idaide`=tai.`idaide`
JOIN text_author ta ON ta.`idtext`=tai.`idtext`
JOIN persons p ON ta.`idperson`=p.`idperson`
WHERE ai.`idaidecontact`=' . $idaidecontact . '
GROUP BY p.`idperson`';
$authors = $this->queryAll($sql);
if (!empty($authors)) {
return $authors;
} else {
return array();
}
}
// }}}
// {{{ countTextsSpectacles()
/** Compter les spectacles montés à partir d'un texte ayant bénéficié de l'aide à la création
*
*
* @access public
* @return array
*/
public function countTextsSpectacles($idaidecontact = null)
{
$sql = 'SELECT COUNT(DISTINCT(ts.`idspectacle`))
FROM text_spectacle ts
JOIN text_aide tai ON tai.`idtext`=ts.`idtext`
JOIN aides ai ON ai.`idaide`=tai.`idaide`
WHERE ai.`idaidecontact`=' . $idaidecontact;
try {
$res = $this->queryOne($sql);
return $res;
} catch (\Throwable $e) {
return 0;
}
}
// }}}
}