Title: Get total registered users in Ion-Auth Library
Tags: codeigniter;ion-auth
Question: Is there a method in Ion Auth library that could get total number of registered users. I know one way could be 

```$users = $this-&gt;ion_auth-&gt;users()-&gt;result();
sizeof($users);
```

But this method looks very resourceful process to get just a number. Any suggestion other than writing our own method for it?



Here is another answer: You can use:

```$usersCount = $this-&gt;db-&gt;count_all_results('users');// assuming table name
```

Docs.

Or 

```$usersCount = $this-&gt;db-&gt;count_all('my_table');
```

Docs.


Here is another answer: There is no native method in ion auth to do this. However, it is very easy to do. Tpojka has the correct answer. I would just like to add that if by registered you mean 'active' then you can do this:

```$this-&gt;db-&gt;where('active', '1');
$total_users = $this-&gt;db-&gt;count_all_results('your_users_table_name');
```

Further, as ```users()``` is an db object you can easily do this as well:

```$total_users = $this-&gt;ion_auth-&gt;users()-&gt;num_rows();
```

and also something like this (haven't tested) but IonAuth has a where method built in:

```$total_users = $this-&gt;ion_auth-&gt;where('active', '1')-&gt;users()-&gt;num_rows();
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:11/12/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<codeigniter><ion-auth>', 'Title': 'Get total registered users in Ion-Auth Library', 'ViewCount': 238, 'id': 47249277, 'user_AboutMe': '', 'user_AccountId': 3509056.0, 'user_DisplayName': 'Syed Sajid', 'user_Reputation': 1340.0, 'user_Views': 223.0, 'user_id': 2933864.0}}