public function Check($new) { $E = array(); if (strlen($this->getDNI()) < 7) { $E[] = "No s'ha entrat el DNI o �s incorrecte"; } if (strlen($this->getNom()) < 1) { $E[] = "No s'ha entrat el NOM"; } if (strlen($this->getCog1()) < 1) { $E[] = "Heu d'entrar els COGNOMS."; } if (strlen($this->getMobil()) < 1 && strlen($this->getTelefon()) < 1 && strlen($this->getEmail()) < 1) { $E[] = "Heu d'entrar algun TEL�FON o CORREU ELECTR�NIC."; } $C = new Criteria(); $C->add(UsuarisPeer::DNI, $this->getDNI(), Criteria::EQUAL); if (UsuarisPeer::doCount($C) > 0 && $new) { $E[] = "El DNI ja existeix."; } return $E; }
/** * RETORNA CORRECTE SI EL DNI TÉ UN FORMAT CORRECTE. **/ public function ValidaDNI($DNI, $new = true) { $DNI = trim($DNI); $correcte = ereg('((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)', $DNI); if ($new) { $C = new Criteria(); $C->add(UsuarisPeer::DNI, $DNI, CRITERIA::EQUAL); $correcte = UsuarisPeer::doCount($C) == 0; //Només serà correcte si no existeix } return $correcte; }
/** * Returns the number of related Usuaris objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Usuaris objects. * @throws PropelException */ public function countUsuariss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(NivellsPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collUsuariss === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(UsuarisPeer::NIVELLS_IDNIVELLS, $this->idnivells); $count = UsuarisPeer::doCount($criteria, false, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(UsuarisPeer::NIVELLS_IDNIVELLS, $this->idnivells); if (!isset($this->lastUsuarisCriteria) || !$this->lastUsuarisCriteria->equals($criteria)) { $count = UsuarisPeer::doCount($criteria, false, $con); } else { $count = count($this->collUsuariss); } } else { $count = count($this->collUsuariss); } } return $count; }