Exemplo n.º 1
0
function getPass($userId)
{
    $query = "select pass.word from pass ";
    $query .= "inner join users on users.id=pass.user ";
    $query .= "where users.id={$userId}";
    $pass = reset(returnStuff($query));
    return $pass;
}
Exemplo n.º 2
0
function userScheduleExists($user, $scheduleId)
{
    $query = "select count(id) from user_schedule ";
    $query .= "where schedule={$scheduleId} and user={$user}";
    $count = reset(returnStuff($query));
    if ($count > 0) {
        return true;
    }
    return false;
}
Exemplo n.º 3
0
function updateIndustry($user)
{
    $newValue = $_POST["value"];
    $userIndustryId = $_POST["sid"];
    // get old industry id
    $query = "select industry from user_industries where id = {$userIndustryId} ";
    $oldIndustryId = reset(returnStuff($query));
    // if new value does not exist in industries, create it.
    $query = "select count(id) from industries where name = \"{$newValue}\" ";
    $count = reset(returnStuff($query));
    if ($count < 1) {
        /*
        $query = "insert into industries (name) values (\"$newValue\") ";
        if ( booleanReturn($query) !== true )
            return "error inserting new industry " ;
        */
        if (insertIndustry($user, $newValue) !== true) {
            return "error inserting new industry ";
        }
    }
    // either way, get industry id
    $query = "select id from industries where name = \"{$newValue}\" ";
    $newIndustryId = reset(returnStuff($query));
    if ($newIndustryId === $oldIndustryId) {
        // then nothing needs to be done, and we can go home
        return true;
    }
    // otherwise, we have to update the user_industries table to point at the new industry,
    // and check if any other users are tracking the $oldIndustryId.
    // If no one else is tracking, then we have to delete it.
    // update user_industries first
    $query = "update user_industries set industry = {$newIndustryId} where id = {$userIndustryId}";
    if (booleanReturn($query) !== true) {
        return "error inserting new user_industry ";
    }
    // now count the users for the old industry
    $query = "select count(id) from user_industries where industry = {$oldIndustryId} ";
    $count = reset(returnStuff($query));
    if ($count < 1) {
        $query = "delete from industries where id = {$oldIndustryId} ";
        return booleanReturn($query);
    }
    return true;
}