Query in cfc returns [n] elements locally, but repeats the first element [n] times on a live site

I am new to ColdBox (and generally to mvc) and trying to figure it out myself, to no avail. The search function works great on our treatment site, and I try to keep my feet wet by switching them to mvc, gradually.

On my mvc test site, I have a query that, when executed on my local machine, correctly returns the expected elements. But when it runs on a live site, it repeats the first element, although there are a lot of elements in the returned array.

Local computer: ColdBox 4.3, Lucee 4.5.5, MySQL 5.6.37, PHPMyAdmin 4.4.15

Live: ColdBox 4.3, ACF 2016, MySQL 5.7, PHPMyAdmin 4.6.6

Here is the function in my CFC:

function getMilestonesByDate(required string pickedMonth='', required string pickedDay='') {

    transaction {
        queryMilestonesByDate = queryExecute("
            SELECT  tbl_milestones.ID as milestoneID, tbl_milestones.event, tbl_milestones.date
            FROM tbl_milestones
            WHERE MONTH(tbl_milestones.date) = :pickedMonth AND DAY(tbl_milestones.date) = :pickedDay AND YEAR(tbl_milestones.date) != 1111
            ORDER BY tbl_milestones.date ASC
        ", {
            pickedMonth: {value: arguments.pickedMonth, cfsqltype: "cf_sql_varchar"},
            pickedDay: {value: arguments.pickedDay, cfsqltype: "cf_sql_varchar"}
            }   
        );
    }

    milestonesByDate = arrayNew(1);

    for (row in queryMilestonesByDate) {
        returnStruct = StructNew();
        returnStruct["milestoneID"] = queryMilestonesByDate.milestoneID;
        returnStruct["event"] = queryMilestonesByDate.event;
        returnStruct["date"] = dateFormat(queryMilestonesByDate.date, "full");
        arrayAppend(milestonesByDate, returnStruct);
    }

    return serializeJSON(milestonesByDate);
}

, . , 26 - 1986 1995 . 1986 .

SQL PHPMyAdmin :

SELECT tbl_milestones.ID as milestoneID, tbl_milestones.event, tbl_milestones.date 
FROM tbl_milestones 
WHERE MONTH(tbl_milestones.date) = '12' AND DAY(tbl_milestones.date) = '26' AND YEAR(tbl_milestones.date) != 1111 
ORDER BY tbl_milestones.date ASC 

, . - - , . , :

function showMilestonesByDate( event, rc, prc ) {
    prc.milestonesByDate = milestoneModel.getMilestonesByDate(pickedMonth,pickedDay);
    event.renderData( type="json", data=prc.milestonesByDate );
}

jQuery UI datepicker. , - , . , , datepicker .

, , mvc , ! !

UPDATE: prc.milestonesByDate :

[{ "": ", 26 1986 ", "": " -34", "milestoneID": 435}, { "": ", 26 , 1995", "": " - HAL Dhruv (Protoype PT4)", "milestoneID": 428}]

:

[{ "": ", 26 1986 ", "milestoneID": 435, "": " -34" }, { "": ", 26 , 1986", "milestoneID": 435, "": " -34" }]

+4
1

, for ACF Lucee .

. , for Lucee <cfloop query="">. ACF. ACF row queryMilestonesByDate.

for (row in queryMilestonesByDate) {
    returnStruct = StructNew();
    returnStruct["milestoneID"] = queryMilestonesByDate.milestoneID;
    returnStruct["event"] = queryMilestonesByDate.event;
    returnStruct["date"] = dateFormat(queryMilestonesByDate.date, "full");
    arrayAppend(milestonesByDate, returnStruct);
}

, , ACF, Lucee, ( , for (row in queryMilestonesByDate)).

for (row in queryMilestonesByDate) {
    returnStruct = StructNew();
    returnStruct["milestoneID"] = row.milestoneID;
    returnStruct["event"] = row.event;
    returnStruct["date"] = dateFormat(row.date, "full");
    arrayAppend(milestonesByDate, returnStruct);
}

, .

ACF

Lucee

+4

Source: https://habr.com/ru/post/1691374/


All Articles