Welcome Guest, Not a member yet? Register   Sign In
How not to get selected data
#1

(This post was last modified: 07-06-2017, 02:57 AM by wolfgang1983.)

Hi, I have my code below I would like to be able to use 'users.*' to be able to get the users data how ever is there a way in select not to get the password but gets the all of other data.

Currently it gets all users data include password. I don't want it do get password.

PHP Code:
public function get_user($column ''$id '')
{
    
$this->db->select('users.*, user_groups.*');
    
$this->db->from($this->db->dbprefix 'users''LEFT');
    
$this->db->join('user_groups''user_groups.user_group_id = users.user_group_id''LEFT');
    
$this->db->where("users.user_id"$id);
    
$user_query $this->db->get();

    return 
$user_query->row_array();
        

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

You would need to specify the fields something like below.

Code:
SELECT tbl_a.column1 , tbl_a.column2
      tbl_b.column1 , tbl_b.column2
FROM   tbl_a , tbl_b
WHERE  tbl_a.commonfield=tbl_b.commonfield
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(07-06-2017, 03:07 AM)InsiteFX Wrote: You would need to specify the fields something like below.

Code:
SELECT tbl_a.column1 , tbl_a.column2
      tbl_b.column1 , tbl_b.column2
FROM   tbl_a , tbl_b
WHERE  tbl_a.commonfield=tbl_b.commonfield

I  know all that was wondering if just can use users.* only and have a some thing in there not to get password other wise I will just have to do it the long way.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

There is no "reverse" select that I know of.
It is recommended to always use the field names. Its good practice NOT to use the * in the select.
The * is more for the newbie programmers that dont know any better. (There are of course exceptions where * is perfectly legitimate)
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#5

You could always just unset the item:

PHP Code:
$result $user_query->row_array();
unset(
$result['user_password']);
return 
$result

However, I would prefer to just select the columns I need rather than do the above.
Reply
#6

(07-06-2017, 10:12 AM)PaulD Wrote: You could always just unset the item:

PHP Code:
$result $user_query->row_array();
unset(
$result['user_password']);
return 
$result

However, I would prefer to just select the columns I need rather than do the above.

Thanks for that.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#7

Strictly speaking, who cares if password is return, it is "encrypted" in db, correct?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB