示例#1
0
 public function filter($c, $filters)
 {
     $filters_key = array_keys($filters);
     foreach ($filters_key as $key) {
         $value = $filters[$key];
         if ($value == '' || $value == null) {
             continue;
         }
         if ($key == 'DEPARTMENT_ID') {
             $c->addJoin(DepartmentPeer::ID, AcademicCalendarPeer::DEPARTMENT_ID);
             $c->addJoin(StudentPeer::ACADEMIC_CALENDAR_ID, AcademicCalendarPeer::ID);
             $c->addJoin(VAbsenceStudentPeer::STUDENT_ID, StudentPeer::ID);
             $column = DepartmentPeer::getTableMap()->getColumn('ID');
         } elseif ($key == 'CODE_CLASS') {
             $c->addJoin(StudentPeer::CLASS_GROUP_ID, ClassGroupPeer::ID);
             $c->addJoin(VAbsenceStudentPeer::STUDENT_ID, StudentPeer::ID);
             $column = ClassGroupPeer::getTableMap()->getColumn('NAME');
         } elseif ($key == 'CODE') {
             $c->addJoin(VAbsenceStudentPeer::STUDENT_ID, StudentPeer::ID);
             $column = StudentPeer::getTableMap()->getColumn('CODE');
         } elseif ($key == 'NAME') {
             $c->addJoin(VAbsenceStudentPeer::STUDENT_ID, StudentPeer::ID);
             $column = StudentPeer::getTableMap()->getColumn('NAME');
         } else {
             $column = VAbsenceStudentPeer::getTableMap()->getColumn($key);
         }
         $name = $column->getFullyQualifiedName();
         $creoleType = $column->getCreoleType();
         if ($creoleType == CreoleTypes::TIMESTAMP) {
             $c->add($name, $value, Criteria::LIKE);
         } else {
             if ($creoleType == CreoleTypes::DATE) {
                 $c->add($name, $value, Criteria::LIKE);
             } else {
                 if ($creoleType == CreoleTypes::INTEGER) {
                     $c->add($name, $value, Criteria::EQUAL);
                 } else {
                     if ($creoleType == CreoleTypes::VARCHAR) {
                         $c->add($name, "%{$value}%", Criteria::LIKE);
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = VAbsenceStudentPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setStudentId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTime($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCode($arr[$keys[2]]);
     }
 }
 public static function doValidate(VAbsenceStudent $obj, $cols = null)
 {
     $columns = array();
     if ($cols) {
         $dbMap = Propel::getDatabaseMap(VAbsenceStudentPeer::DATABASE_NAME);
         $tableMap = $dbMap->getTable(VAbsenceStudentPeer::TABLE_NAME);
         if (!is_array($cols)) {
             $cols = array($cols);
         }
         foreach ($cols as $colName) {
             if ($tableMap->containsColumn($colName)) {
                 $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
                 $columns[$colName] = $obj->{$get}();
             }
         }
     } else {
     }
     $res = BasePeer::doValidate(VAbsenceStudentPeer::DATABASE_NAME, VAbsenceStudentPeer::TABLE_NAME, $columns);
     if ($res !== true) {
         $request = sfContext::getInstance()->getRequest();
         foreach ($res as $failed) {
             $col = VAbsenceStudentPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
             $request->setError($col, $failed->getMessage());
         }
     }
     return $res;
 }