validation ignores one of the conditions - yii
Tag : php , By : lonehunter01
Date : March 29 2020, 07:55 AM
will help you I want to validate before save and see if the store_id/period exists. But it's strange, it's validating for the entire store_idS, but it's suppose to see only one of the id. , Check this $criteria->addBetweenCondition('date_from', $this->date_from, $this->date_to);
$criteria->addBetweenCondition('date_to', $this->date_from, $this->date_to, 'OR');
$criteria->compare('store_id',$this->store_id);
|
Paginate ignores conditions
Date : March 29 2020, 07:55 AM
Hope that helps when I try to run this code, it will not change my query, the condition is just not taken: , What @ndm means is replace your existing code with this: $this->Paginator->settings['conditions'] = array(
'Product.campaign_id' => $this->request->data['Campaign']['campaign_id']
)
$this->set('products', $this->Paginator->paginate());
|
Why does the switch statement run only the default and ignores the remaining conditions?
Date : March 29 2020, 07:55 AM
it should still fix some issue { origin } creates a new object with a single property. This is not strict equal to the req.query, the value for comparing. You need values who are comparable in a switch statement. In this case you could take a strange comparison with false, assuming the values have either a truthy value or undefined. switch (false) {
case !origin: {
const data = await Trips.tripModel().select('*', `WHERE origin='${origin}'`);
if (!data[0]) return nullResponse(res, 'No trips available from here');
return successResponse(res, 200, data);
}
case !destination: {
const data = await Trips.tripModel().select('*', `WHERE destination='${destination}'`);
if (!data[0]) return nullResponse(res, 'No trips available to this destination');
return successResponse(res, 200, data);
}
}
|
Why does 'if statement' ignores conditions or reads them as if they are not true when they actually are?
Tag : php , By : user157654
Date : March 29 2020, 07:55 AM
Any of those help i think you want to do this, because you want to restrict this page if the user has not a required role: if( $userrole !== 'Administrator' &&
$userrole !== 'Manager' &&
$userrole !== 'Product Hunter' &&
$userrole !== 'Product Selector' &&
$userrole !== 'Analytic' &&
$userrole !== 'Order Manager'){
header('Location: ../dashboard.php');
die;
}
else{
//code here
}
$aAllowedRoles = array(
'Administrator',
'Manager',
'Product Hunter',
'Product Selector',
'Analytic',
'Order Manager'
);
if ( !in_array($userrole, $aAllowedRoles) ) {
header('Location: ../dashboard.php');
die;
}
// code here
|
My code ignores subsequent if and while conditions
Tag : java , By : Topher Cyll
Date : March 29 2020, 07:55 AM
I hope this helps you . That's because your while loops are infinite loops, and because you should reverse the order of your if statements. You never get user input inside any of your loops, so there's no way for the values to change. Once age < 30, for example, age will always be less than 30, so this loop will never end and it'll never run any other part of your program other than what's inside that particular while loop. For that matter, you're currently hardcoding age and score to 0 and never changing them - I assume that you'll want to get user input or something here. if (age < 30) {
if (score < 8) {
// ...
}
else if (score < 10) {
// ...
}
// Etc.
}
else if (age < 40) {
// ...
}
else if (age < 60) {
// ...
}
// Etc.
|