コード例 #1
0
function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier)
{
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $selectspec = array('columns' => array('flags' => 'COUNT(*)'), 'source' => '^userfavorites WHERE userid=$ AND entitytype=$', 'arrayvalue' => 'flags', 'single' => true);
    switch ($entitytype) {
        case QA_ENTITY_USER:
            $selectspec['source'] .= ' AND entityid=(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)';
            break;
        case QA_ENTITY_TAG:
            $selectspec['source'] .= ' AND entityid=(SELECT wordid FROM ^words WHERE word=$ LIMIT 1)';
            break;
        case QA_ENTITY_CATEGORY:
            $selectspec['source'] .= ' AND entityid=(SELECT categoryid FROM ^categories WHERE backpath=$ LIMIT 1)';
            $identifier = qa_db_slugs_to_backpath($identifier);
            break;
        default:
            $selectspec['source'] .= ' AND entityid=$';
            break;
    }
    $selectspec['arguments'] = array($userid, $entitytype, $identifier);
    return $selectspec;
}
コード例 #2
0
function qa_db_slugs_to_category_id_selectspec($slugs)
{
    return array('columns' => array('categoryid'), 'source' => '^categories WHERE backpath=$', 'arguments' => array(qa_db_slugs_to_backpath($slugs)), 'arrayvalue' => 'categoryid', 'single' => true);
}