/**
  * get nb comment for an id and a type
  * @param string $id identifiant
  * @param string $type
  */
 function getNbComment($id, $type)
 {
     $query = 'select count(id_cmt) as nbComment from "comment" where id_cmt=\'' . $id . '\' and type_cmt=\'' . $type . '\'';
     $dbWidget =& CopixDBFactory::getDbWidget();
     $count = $dbWidget->fetchFirst($query);
     $toReturn = $count->nbComment;
     return $toReturn;
 }
 function findAll()
 {
     $dbWidget =& CopixDBFactory::getDbWidget();
     return $dbWidget->fetchAllUsing($this->_selectQuery, 'CompiledDAORecordContract');
 }
 /**
  * Updates the users informations
  * @param string $login the login
  * @param array $informations the informations to update
  * @return boolean
  */
 function updateInformations($login, $informations)
 {
     $ct =& CopixDBFactory::getConnection();
     //Creating hash table to get field names from properties
     foreach ($this->fieldPropList as $key => $value) {
         $hashProperties[$value] = $key;
     }
     $toUpdate = array();
     foreach ($informations as $name => $value) {
         if (isset($hashProperties[$name])) {
             $toUpdate[$hashProperties[$name]] = $ct->quote($value);
         }
     }
     if (count($toUpdate)) {
         $dbw = CopixDBFactory::getDbWidget();
         return $dbw->doUpdate($this->userTable, $toUpdate, $condition);
     }
     return false;
 }
 /**
  * Creates a user.
  */
 function createUser($informations)
 {
     $ct =& CopixDBFactory::getConnection();
     //Creating hash table to get field names from properties
     foreach ($this->fieldPropList as $key => $value) {
         $hashProperties[$value] = $key;
     }
     $toInsert = array();
     foreach (get_object_vars($informations) as $name => $value) {
         if (isset($hashProperties[$name])) {
             $toInsert[$hashProperties[$name]] = $ct->quote($value);
         }
     }
     $toInsert[$this->passwordField] = $ct->quote($this->cryptPassword($informations->password));
     if (count($toInsert)) {
         $dbw = CopixDBFactory::getDbWidget();
         return $dbw->doInsert($this->userTable, $toInsert);
     }
     return false;
 }