Adding points for each user
I want to add the points for each of user identified by mail address, Points are added to user whenever he does a task, different points for different task and need to sum all the points each day, this is what I am trying to and one more thing I am working on zend.
public function sumPoint($user_email)
{
$select = $this->getAdapter()->select()
->from('tbl_points', array('sum(points)'))
->where('emailAddress = ?', $user_em开发者_运维技巧ail)
->order('createdOn DESC');
$totalpoints= $this->getAdapter()->fetchOne($select);
}
I am not sure if it is correct please let me know.
Why don't you use a view in your database to handle this ?
Something like :
CREATE VIEW V_USERS AS (
SELECT a.*,
(SELECT SUM(points) FROM tbl_points where tbl_points.emailAdress = a.emailAdress) sumPoints
FROM your_user_table a
);
And then, in Zend, you set the authentification table to 'V_USERS', so you'll get the number of points always ok, and it will avoid you to do the process by yourself.
精彩评论