Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: student restrictions change SQL query #218

Merged
merged 17 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/controllers/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,17 @@ public function actionOutOfTownStudentsReport()
public function actionStudentSpecialFood()
{
$sql = "SELECT si.inep_id , si.name as nome_aluno, si.birthday, sr.* FROM student_identification si
JOIN student_restrictions sr ON(sr.student_fk = si.id)";
JOIN student_restrictions sr ON(sr.student_fk = si.id)
WHERE sr.celiac != 0
OR sr.celiac != 0
OR sr.diabetes != 0
OR sr.hypertension != 0
OR sr.iron_deficiency_anemia != 0
OR sr.sickle_cell_anemia != 0
OR sr.lactose_intolerance != 0
OR sr.malnutrition != 0
OR sr.obesity != 0
OR sr.`others` != ''";

$result = Yii::app()->db->createCommand($sql)->queryAll();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ CREATE TABLE `student_restrictions` (
`lactose_intolerance` tinyint(1) NOT NULL DEFAULT '0',
`malnutrition` tinyint(1) NOT NULL DEFAULT '0',
`obesity` tinyint(1) NOT NULL DEFAULT '0',
`others` varchar(200) DEFAULT NULL,
`others` varchar(200) NOT NULL DEFAULT "",
PRIMARY KEY (`id`),
KEY `student_food_restrictions_FK` (`student_fk`),
CONSTRAINT `student_food_restrictions_FK` FOREIGN KEY (`student_fk`) REFERENCES `student_identification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

ALTER TABLE `io.escola.demo`.student_identification DROP COLUMN food_restrictions;
INSERT INTO student_restrictions (student_fk, others)
SELECT id, food_restrictions
FROM student_identification;

UPDATE student_restrictions
SET others = ''
WHERE others = 'NAO' OR others = 'NENHUMA';