خرید بک لینک

Vote count: 0

I am working on PHPStorm with a codeigniter framework and the MVC architecture. I need a function in my model that would query the sysuser table in my database and return the uid (User Id) when the username is passed.

sysuser Table structure

+---------------+----------------+-----------------+
|   uid         |     name       |     username    |
+---------------+----------------+-----------------+
|      1        |       kim      |    kcdla        |
+---------------+----------------+-----------------+
|      2        |       Sam      |    sammyG       |
+---------------+----------------+-----------------+

In my function, if I pass, for example, the username kcdla I need to retrieve the uid as 1 so that I can store this to a variable as $uid and return it to another function that will use it. But currently the result is an array and when I tried to access only the first cell from the array, I get an Exception.

Code in Context

public function getUserUid($username)
{
    $this->db->select("*");
    $this->db->from('sysuser');
    $this->db->where('username',$username);
    $query = $this->db->get();
    $tableArray = $query->result();
    foreach ($tableArray as $row) {
        $uid = $row->uid;
    }
    return $uid;
}

I need to use the $uid value returned from this method within another method as shown below.

public function getUserDetails($username)
{
    $uid = $this->userModel->getUserUid($username);
    $this->db->select("*");
    $this->db->from('userProfile');
    $this->db->where('uid',$uid);
    $query = $this->db->get();
    return $query->result();

}

Any suggestions in this regard will be highly appreciated.

asked 1 min ago

برچسب: get a single file from git,get a single book printed,get a single file from github,get a single check from bank,get a single page from pdf,get a single on itunes,get a single join crossword clue,get a single value from list c,get a single post wordpress,get a single value from mysql php, نویسنده: استخدام کار تاريخ: شنبه 24 مهر 1395 ساعت: 0:24

صفحه بندی