Hi,
I have url-column in database table (loremipsum) with unique values. I'm trying to check if value ($_POST['url']) already exist on table. If $_POST['url'] doesn't match to database url-column, getObject should return empty - right?
Why this is not working?
$object = $modx->getObject('loremipsum',array('url'=>$_POST['url']));
if (!$object) {
$modx->log(modX::LOG_LEVEL_ERROR, 'empty');
//This is not working
} else {
$modx->log(modX::LOG_LEVEL_ERROR, 'url exist');
//This is working
}
and vice versa
$object = $modx->getObject('loremipsum',array('url'=>$_POST['url']));
if ($object) {
$modx->log(modX::LOG_LEVEL_ERROR, 'url exist');
//This working
} else {
$modx->log(modX::LOG_LEVEL_ERROR, 'empty');
//This is not working
}
So i have problems to execute script if $object returns empty (or null)