public static function ExtractForm($data, $singleResult = false, $FormsExtension = '', $ChoiceExtension = '', $isResult = true) { // generates an assoc array of an forms by using a defined // list of its attributes $forms = DBJson::getObjectsByAttributes($data, Form::getDBPrimaryKey(), Form::getDBConvert(), $FormsExtension); // generates an assoc array of choices by using a defined // list of its attributes $choices = DBJson::getObjectsByAttributes($data, Choice::getDBPrimaryKey(), Choice::getDBConvert(), $ChoiceExtension); // concatenates the forms and the associated choices $res = DBJson::concatObjectListResult($data, $forms, Form::getDBPrimaryKey(), Form::getDBConvert()['FO_choices'], $choices, Choice::getDBPrimaryKey(), $ChoiceExtension, $FormsExtension); if ($isResult) { // to reindex $res = array_values($res); $res = Form::decodeForm($res, false); if ($singleResult) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
public static function ExtractChoice($data, $singleResult = false, $ChoiceExtension = '', $isResult = true) { // generates an assoc array of choices by using a defined list of // its attributes $res = DBJson::getResultObjectsByAttributes($data, Choice::getDBPrimaryKey(), Choice::getDBConvert(), $ChoiceExtension); if ($isResult) { // to reindex $res = array_values($res); $res = Choice::decodeChoice($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }