SOCIALENGINE:获得用户的性别

时间:2012-02-17 17:07:25

标签: socialengine

SocialEngine4:如何使用sql查询获取用户的性别?

4 个答案:

答案 0 :(得分:2)

$subject = Engine_Api::_()->core()->getSubject(); //Get user

$fields = $subject->fields()->getFieldsValuesByAlias();
$gender = $fields['gender'];

$this->view->gender = $gender;

答案 1 :(得分:1)

使用下面列出的代码:

<?php
$currentUserID=Engine_Api::_()->user()->getViewer()->getIdentity();
$sSqlInviter="select gender from engine4_user_fields_search where item_id=".$currentUserID;
$dbInviterSqli=Zend_Db_Table_Abstract::getDefaultAdapter();
$stmtInviter=$dbInviterSqli->query($sSqlInviter);
$rowInviter=$stmtInviter->fetch();
$gender=$rowInviter['gender'];
if($gender==2) 
  echo "<b> Male</b>";
else
  echo "<b> Female</b>";
?>

答案 2 :(得分:1)

$viewer = Engine_Api::_()->user()->getViewer();
$fields = Engine_Api::_()->fields()->getFieldsValuesByAlias($viewer);
echo $fields['gender'];

答案 3 :(得分:0)

您使用的是默认个人资料问题吗?然后:

From engine4_ser_fields_option

特定字段有和选项ID。