私は以下のコードを使って、データベースでのアクティベーションを確認しています。私が今、何もしたくないのは、私を有効にする最善の方法は、特定のアクティベーションコードにリンクされているユーザー名の最初の名前を抽出することです。userFirstName
?どのようにコントローラに$data['userFirstName'] = What
として渡すのでしょうか。Codeigniter - >その他のデータの抽出
モデル:今コントローラ側で
// setting up the query
$this->db->select('userID, userFirstName');
$this->db->from('users');
$this->db->where('userActiveCode', $activateCode);
$result = $this->db->get();
if($result->num_rows == 1)
{
$this->db->set('userActive', 1);
$this->db->where('userActiveCode', $activateCode);
$this->db->update('users');
return $result->row()->userFirstName;
}else{
return FALSE;
}
、confirmUser
:あなたはあまりにもuserFirstName
をつかむためにあなたのselect文を更新した場合、あなたはあなたの結果でそれにアクセスする必要があります
function confirmUser($activateCode)
{
if($activateCode == '')
{
return FALSE;
}
//Selects the userID where the given URI activateCode = ?
$this->db->select('userID');
$this->db->from('users');
$this->db->where('userActiveCode', $activateCode);
$result = $this->db->get();
if($result->num_rows == 1) // If the above result is = 1 then update the userActive row else it will fail
{
$this->db->set('userActive', 1);
$this->db->where('userActiveCode', $activateCode);
$this->db->update('users');
return TRUE;
}else{
return FALSE;
}
}
もう一度rjzさん、「TRUE」の中でこれを行うことはできますか? &モデルは値を必要とするので、私はコントローラを介してどのように渡すでしょうか? –
確かに、私はもう助けてもらえませんでした!ええ、私はそれをあなたの 'TRUE'と同じ条件に入れます。実際には、戻り値として使用することを検討することもできます。暗黙の等号( '=='ではなく '===')を使用している限り、相手側では 'true'をテストします。私の答えを更新しています... – rjz
ありがとう、とにかく私は$ this-> users_model-> confirmUser($ activateCode) - > userFirstNameのようにアクセスできます。 –