本文整理汇总了PHP中Profile::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::query方法的具体用法?PHP Profile::query怎么用?PHP Profile::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGraders
static function getGraders($groupid)
{
$qry = 'SELECT profile.* ' . 'FROM profile JOIN grades_group ' . 'ON profile.id = grades_group.userid ' . 'WHERE grades_group.groupid = ' . $groupid;
$graders = new Profile();
$graders->query($qry);
return $graders;
}
示例2: updateUserUrls
function updateUserUrls()
{
printfnq("Updating user URLs...\n");
// XXX: only update user URLs where out-of-date
$qry = "SELECT * FROM profile order by id asc";
$pflQry = new Profile();
$pflQry->query($qry);
$members = array();
while ($pflQry->fetch()) {
$members[] = clone $pflQry;
}
$pflQry->free();
foreach ($members as $member) {
$user = $member->getUser();
printfv("Updating user {$user->nickname}...");
try {
$profile = $user->getProfile();
updateProfileUrl($profile);
updateAvatarUrls($profile);
// Broadcast for remote users
common_broadcast_profile($profile);
} catch (Exception $e) {
printv("Error updating URLs: " . $e->getMessage());
}
printfv("DONE.");
}
}
示例3: getTagged
static function getTagged($tagger, $tag)
{
$profile = new Profile();
$profile->query('SELECT profile.* ' . 'FROM profile JOIN profile_tag ' . 'ON profile.id = profile_tag.tagged ' . 'WHERE profile_tag.tagger = ' . $tagger . ' ' . 'AND profile_tag.tag = "' . $tag . '" ');
$tagged = array();
while ($profile->fetch()) {
$tagged[] = clone $profile;
}
return $tagged;
}
示例4: getMembers
function getMembers($offset = 0, $limit = null)
{
$qry = 'SELECT profile.* ' . 'FROM profile JOIN group_member ' . 'ON profile.id = group_member.profile_id ' . 'WHERE group_member.group_id = %d ' . 'ORDER BY group_member.created DESC ';
if ($limit != null) {
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
$members = new Profile();
$members->query(sprintf($qry, $this->id));
return $members;
}
示例5: get_missing_profiles
/**
* Check for profiles in the given id range that are missing, presumed deleted.
*
* @param int $start beginning profile.id, inclusive
* @param int $end final profile.id, inclusive
* @return array of integer profile.ids
* @access private
*/
function get_missing_profiles($start, $end)
{
$query = sprintf("SELECT id FROM profile WHERE id BETWEEN %d AND %d", $start, $end);
$profile = new Profile();
$profile->query($query);
$all = range($start, $end);
$known = array();
while ($row = $profile->fetch()) {
$known[] = intval($profile->id);
}
unset($profile);
$missing = array_diff($all, $known);
return $missing;
}
示例6: showResults
/**
* Search for users matching the query and spit the results out
* as a quick-n-dirty JSON document
*
* @return void
*/
function showResults()
{
$people = array();
$profile = new Profile();
$search_engine = $profile->getSearchEngine('profile');
$search_engine->set_sort_mode('nickname_desc');
$search_engine->limit(0, 10);
$search_engine->query(strtolower($this->query . '*'));
$cnt = $profile->find();
if ($cnt > 0) {
$sql = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id ' . ' AND LEFT(LOWER(profile.nickname), ' . strlen($this->query) . ') = \'%s\' ' . ' LIMIT 0, 10';
$profile->query(sprintf($sql, $this->query));
}
while ($profile->fetch()) {
$people[] = $profile->nickname;
}
header('Content-Type: application/json; charset=utf-8');
print json_encode($people);
}
示例7: getTaggedSubscriptions
function getTaggedSubscriptions($tag, $offset = 0, $limit = null)
{
$qry = 'SELECT profile.* ' . 'FROM profile JOIN subscription ' . 'ON profile.id = subscription.subscribed ' . 'JOIN profile_tag on (profile_tag.tagged = subscription.subscribed ' . 'AND profile_tag.tagger = subscription.subscriber) ' . 'WHERE subscription.subscriber = %d ' . "AND profile_tag.tag = '%s' " . 'AND subscription.subscribed != subscription.subscriber ' . 'ORDER BY subscription.created DESC ';
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
$profile = new Profile();
$profile->query(sprintf($qry, $this->id, $tag));
return $profile;
}
示例8: showContent
/**
* Whips up a query to get a list of profiles based on the provided
* people tag and page, initalizes a ProfileList widget, and displays
* it to the user.
*
* @return nothing
*/
function showContent()
{
$profile = new Profile();
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
if (common_config('db', 'type') == 'pgsql') {
$lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$lim = ' LIMIT ' . $offset . ', ' . $limit;
}
// XXX: memcached this
$qry = 'SELECT profile.* ' . 'FROM profile JOIN profile_tag ' . 'ON profile.id = profile_tag.tagger ' . 'WHERE profile_tag.tagger = profile_tag.tagged ' . "AND tag = '%s' " . 'ORDER BY profile_tag.modified DESC%s';
$profile->query(sprintf($qry, $this->tag, $lim));
$ptl = new PeopleTagList($profile, $this);
// pass the ammunition
$cnt = $ptl->show();
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'peopletag', array('tag' => $this->tag));
}
示例9: getBlocked
function getBlocked($offset = 0, $limit = null)
{
$qry = 'SELECT profile.* ' . 'FROM profile JOIN group_block ' . 'ON profile.id = group_block.blocked ' . 'WHERE group_block.group_id = %d ' . 'ORDER BY group_block.modified DESC ';
if ($limit != null) {
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
$blocked = new Profile();
$blocked->query(sprintf($qry, $this->id));
return $blocked;
}
示例10: realpath
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'y';
$longoptions = array('yes');
$helptext = <<<END_OF_HELP
clean_profiles.php [options]
Deletes all profile table entries where the profile does not occur in the
notice table, is not a group and is not a local user. Very MySQL specific I think.
WARNING: This has not been tested thoroughly. Maybe we've missed a table to compare somewhere.
-y --yes do not wait for confirmation
END_OF_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (!have_option('y', 'yes')) {
print "About to delete profiles that we think are useless to save. Are you sure? [y/N] ";
$response = fgets(STDIN);
if (strtolower(trim($response)) != 'y') {
print "Aborting.\n";
exit(0);
}
}
print "Deleting";
$profile = new Profile();
$profile->query('SELECT * FROM profile WHERE ' . 'NOT (SELECT COUNT(*) FROM notice WHERE profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user WHERE user.id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user_group WHERE user_group.profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM subscription WHERE subscriber=profile.id OR subscribed=profile.id) ');
while ($profile->fetch()) {
echo ' ' . $profile->getID() . ':' . $profile->getNickname();
$profile->delete();
}
print "\nDONE.\n";
示例11: register
/**
* Register a new user account and profile and set up default subscriptions.
* If a new-user welcome message is configured, this will be sent.
*
* @param array $fields associative array of optional properties
* string 'bio'
* string 'email'
* bool 'email_confirmed' pass true to mark email as pre-confirmed
* string 'fullname'
* string 'homepage'
* string 'location' informal string description of geolocation
* float 'lat' decimal latitude for geolocation
* float 'lon' decimal longitude for geolocation
* int 'location_id' geoname identifier
* int 'location_ns' geoname namespace to interpret location_id
* string 'nickname' REQUIRED
* string 'password' (may be missing for eg OpenID registrations)
* string 'code' invite code
* ?string 'uri' permalink to notice; defaults to local notice URL
* @return User object
* @throws Exception on failure
*/
static function register(array $fields)
{
// MAGICALLY put fields into current scope
extract($fields);
$profile = new Profile();
if (!empty($email)) {
$email = common_canonical_email($email);
}
// Normalize _and_ check whether it is in use. Throw NicknameException on failure.
$profile->nickname = Nickname::normalize($nickname, true);
$profile->profileurl = common_profile_url($profile->nickname);
if (!empty($fullname)) {
$profile->fullname = $fullname;
}
if (!empty($homepage)) {
$profile->homepage = $homepage;
}
if (!empty($bio)) {
$profile->bio = $bio;
}
if (!empty($location)) {
$profile->location = $location;
$loc = Location::fromName($location);
if (!empty($loc)) {
$profile->lat = $loc->lat;
$profile->lon = $loc->lon;
$profile->location_id = $loc->location_id;
$profile->location_ns = $loc->location_ns;
}
}
$profile->created = common_sql_now();
$user = new User();
$user->nickname = $profile->nickname;
$invite = null;
// Users who respond to invite email have proven their ownership of that address
if (!empty($code)) {
$invite = Invitation::getKV($code);
if ($invite instanceof Invitation && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
}
}
if (isset($email_confirmed) && $email_confirmed) {
$user->email = $email;
}
// Set default-on options here, otherwise they'll be disabled
// initially for sites using caching, since the initial encache
// doesn't know about the defaults in the database.
$user->emailnotifysub = 1;
$user->emailnotifynudge = 1;
$user->emailnotifymsg = 1;
$user->emailnotifyattn = 1;
$user->emailmicroid = 1;
$user->emailpost = 1;
$user->jabbermicroid = 1;
$user->created = common_sql_now();
if (Event::handle('StartUserRegister', array($profile))) {
$profile->query('BEGIN');
$id = $profile->insert();
if ($id === false) {
common_log_db_error($profile, 'INSERT', __FILE__);
$profile->query('ROLLBACK');
// TRANS: Profile data could not be inserted for some reason.
throw new ServerException(_m('Could not insert profile data for new user.'));
}
$user->id = $id;
if (!empty($uri)) {
$user->uri = $uri;
} else {
$user->uri = common_user_uri($user);
}
if (!empty($password)) {
// may not have a password for OpenID users
$user->password = common_munge_password($password, $id);
}
$result = $user->insert();
if ($result === false) {
common_log_db_error($user, 'INSERT', __FILE__);
$profile->query('ROLLBACK');
//.........这里部分代码省略.........
示例12: getSubscribers
function getSubscribers($offset = 0, $limit = null)
{
$qry = 'SELECT profile.* ' . 'FROM profile JOIN subscription ' . 'ON profile.id = subscription.subscriber ' . 'WHERE subscription.subscribed = %d ' . 'AND subscription.subscribed != subscription.subscriber ' . 'ORDER BY subscription.created DESC ';
if ($offset > 0 && !is_null($limit)) {
if ($offset) {
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
}
$profile = new Profile();
$cnt = $profile->query(sprintf($qry, $this->id));
return $profile;
}
示例13: initGroupProfileId
function initGroupProfileId()
{
printfnq("Ensuring all User_group entries have a Profile and profile_id...");
$group = new User_group();
$group->whereAdd('NOT EXISTS (SELECT id FROM profile WHERE id = user_group.profile_id)');
$group->find();
while ($group->fetch()) {
try {
// We must create a new, incrementally assigned profile_id
$profile = new Profile();
$profile->nickname = $group->nickname;
$profile->fullname = $group->fullname;
$profile->profileurl = $group->mainpage;
$profile->homepage = $group->homepage;
$profile->bio = $group->description;
$profile->location = $group->location;
$profile->created = $group->created;
$profile->modified = $group->modified;
$profile->query('BEGIN');
$id = $profile->insert();
if (empty($id)) {
$profile->query('ROLLBACK');
throw new Exception('Profile insertion failed, profileurl: ' . $profile->profileurl);
}
$group->query("UPDATE user_group SET profile_id={$id} WHERE id={$group->id}");
$profile->query('COMMIT');
$profile->free();
} catch (Exception $e) {
printfv("Error initializing Profile for group {$group->nickname}:" . $e->getMessage());
}
}
printfnq("DONE.\n");
}
示例14: register
static function register($fields)
{
if (!empty($fields['userid'])) {
$profile = Profile::getKV('id', $fields['userid']);
if ($profile && !$profile->hasRight(Right::CREATEGROUP)) {
common_log(LOG_WARNING, "Attempted group creation from banned user: " . $profile->nickname);
// TRANS: Client exception thrown when a user tries to create a group while banned.
throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
}
}
$fields['nickname'] = Nickname::normalize($fields['nickname']);
// MAGICALLY put fields into current scope
// @fixme kill extract(); it makes debugging absurdly hard
$defaults = array('nickname' => null, 'fullname' => null, 'homepage' => null, 'description' => null, 'location' => null, 'uri' => null, 'mainpage' => null, 'aliases' => array(), 'userid' => null);
$fields = array_merge($defaults, $fields);
extract($fields);
$group = new User_group();
if (empty($uri)) {
// fill in later...
$uri = null;
}
if (empty($mainpage)) {
$mainpage = common_local_url('showgroup', array('nickname' => $nickname));
}
// We must create a new, incrementally assigned profile_id
$profile = new Profile();
$profile->nickname = $nickname;
$profile->fullname = $fullname;
$profile->profileurl = $mainpage;
$profile->homepage = $homepage;
$profile->bio = $description;
$profile->location = $location;
$profile->created = common_sql_now();
$group->nickname = $profile->nickname;
$group->fullname = $profile->fullname;
$group->homepage = $profile->homepage;
$group->description = $profile->bio;
$group->location = $profile->location;
$group->mainpage = $profile->profileurl;
$group->created = $profile->created;
$profile->query('BEGIN');
$id = $profile->insert();
if ($id === false) {
$profile->query('ROLLBACK');
throw new ServerException(_('Profile insertion failed'));
}
$group->profile_id = $id;
$group->uri = $uri;
if (isset($fields['join_policy'])) {
$group->join_policy = intval($fields['join_policy']);
} else {
$group->join_policy = 0;
}
if (isset($fields['force_scope'])) {
$group->force_scope = intval($fields['force_scope']);
} else {
$group->force_scope = 0;
}
if (Event::handle('StartGroupSave', array(&$group))) {
$result = $group->insert();
if ($result === false) {
common_log_db_error($group, 'INSERT', __FILE__);
// TRANS: Server exception thrown when creating a group failed.
throw new ServerException(_('Could not create group.'));
}
if (!isset($uri) || empty($uri)) {
$orig = clone $group;
$group->uri = common_local_url('groupbyid', array('id' => $group->id));
$result = $group->update($orig);
if (!$result) {
common_log_db_error($group, 'UPDATE', __FILE__);
// TRANS: Server exception thrown when updating a group URI failed.
throw new ServerException(_('Could not set group URI.'));
}
}
$result = $group->setAliases($aliases);
if (!$result) {
// TRANS: Server exception thrown when creating group aliases failed.
throw new ServerException(_('Could not create aliases.'));
}
$member = new Group_member();
$member->group_id = $group->id;
$member->profile_id = $userid;
$member->is_admin = 1;
$member->created = $group->created;
$result = $member->insert();
if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__);
// TRANS: Server exception thrown when setting group membership failed.
throw new ServerException(_('Could not set group membership.'));
}
self::blow('profile:groups:%d', $userid);
if ($local) {
$local_group = new Local_group();
$local_group->group_id = $group->id;
$local_group->nickname = $nickname;
$local_group->created = common_sql_now();
$result = $local_group->insert();
if (!$result) {
common_log_db_error($local_group, 'INSERT', __FILE__);
//.........这里部分代码省略.........
示例15: ensureProfile
function ensureProfile($user)
{
// check to see if there's already a profile for this user
$profileurl = 'http://twitter.com/' . $user->screen_name;
$profile = Profile::staticGet('profileurl', $profileurl);
if ($profile) {
if (defined('SCRIPT_DEBUG')) {
common_debug("Profile for {$profile->nickname} found.");
}
// Check to see if the user's Avatar has changed
$this->checkAvatar($user, $profile);
return $profile->id;
} else {
if (defined('SCRIPT_DEBUG')) {
common_debug('Adding profile and remote profile ' . "for Twitter user: {$profileurl}");
}
$profile = new Profile();
$profile->query("BEGIN");
$profile->nickname = $user->screen_name;
$profile->fullname = $user->name;
$profile->homepage = $user->url;
$profile->bio = $user->description;
$profile->location = $user->location;
$profile->profileurl = $profileurl;
$profile->created = common_sql_now();
$id = $profile->insert();
if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__);
$profile->query("ROLLBACK");
return false;
}
// check for remote profile
$remote_pro = Remote_profile::staticGet('uri', $profileurl);
if (!$remote_pro) {
$remote_pro = new Remote_profile();
$remote_pro->id = $id;
$remote_pro->uri = $profileurl;
$remote_pro->created = common_sql_now();
$rid = $remote_pro->insert();
if (empty($rid)) {
common_log_db_error($profile, 'INSERT', __FILE__);
$profile->query("ROLLBACK");
return false;
}
}
$profile->query("COMMIT");
$this->saveAvatars($user, $id);
return $id;
}
}