Esempio n. 1
0
 public static final function ListImmediateNeighbours($lessonId)
 {
     return CLearnGraphRelation::ListImmediateNeighbours($lessonId);
 }
Esempio n. 2
0
 public static function SetProperty($parentNodeId, $childNodeId, $propertyName, $value)
 {
     global $DB;
     // reset static cache
     self::$arNodesCache = array();
     self::$nodesCached = 0;
     $args_check = $parentNodeId > 0 && $childNodeId > 0 && in_array($propertyName, array('SORT'), true);
     if ($propertyName === 'SORT') {
         // check SORT admitted range: number
         $args_check = $args_check && is_numeric($value) && is_int($value + 0);
     }
     if (!$args_check) {
         throw new LearnException('EA_PARAMS', LearnException::EXC_ERR_GR_SET_PROPERTY);
     }
     $parentNodeId += 0;
     $childNodeId += 0;
     switch ($propertyName) {
         case 'SORT':
             $value = (int) ($value + 0);
             $arFields = array('SORT' => "'" . $value . "'");
             break;
         default:
             throw new LearnException('EA_PARAMS: unknown property name: ' . $propertyName, LearnException::EXC_ERR_GR_SET_PROPERTY);
             break;
     }
     // Update graph edge
     $rc = $DB->Update('b_learn_lesson_edges', $arFields, "WHERE SOURCE_NODE='" . $parentNodeId . "'\n\t\t\t\tAND TARGET_NODE='" . $childNodeId . "'", __LINE__, false, false);
     // we must halt on errors due to bug in CDatabase::Update();
     /**
      * This code will be useful after bug in CDatabase::Update() will be solved
      * and $ignore_errors setted to true in Update() call above.
      */
     if ($rc === false) {
         throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_GR_SET_PROPERTY);
     }
     /*
     This is not correctly, because there is can be update to value, which already set in db. And not affected rows will be.
     Consistent check of existence of relation needs transaction with one more sql-prerequest,
     so don't check it because of perfomance penalties and DB::transactions problems. :(
     		if ($rc->AffectedRowsCount() == 0)
     			throw new LearnException ('EA_NOT_EXISTS', LearnException::EXC_ERR_GR_SET_PROPERTY);
     */
 }