Give something like this a try:
<?php
$user = Users::findFirst(array(
'conditions' =>
'user_email = ?1 and '.
'user_id = ?2',
'bind' => array(
1 => '[email protected]',
2 => 1
)
));
foreach ($user->getUsersEmails() as $user_email) {
$user_email->confirmed = 1;
$user_email->save();
}
Unless user_email is part of UsersEmails model, then try:
<?php
$user = Users::findFirst(array(
'conditions' =>
'user_id = ?1',
'bind' => array(
1 => 1
)
));
foreach ($user->getUsersEmails("user_email = '[email protected]'") as $user_email) {
$user_email->confirmed = 1;
$user_email->save();
}
Or a really condensed version:
<?php
$user = Users::findFirst(1);
foreach ($user->getUsersEmails("user_email = '[email protected]'") as $user_email) {
$user_email->confirmed = 1;
$user_email->save();
}
Or the most condensed version:
<?php
foreach (Users::findFirst(1)->getUsersEmails("user_email = '[email protected]'") as $user_email) {
$user_email->confirmed = 1;
$user_email->save();
}
This assumes, of course, that you've set up a hasMany relationship in your Users and a belongsTo relationship in your UsersEmails models.
I haven't tested it because I don't have your exact use case, but, this should either work or be a huge step in the right direction.