<?php

Doo::loadCore('db/DooModel');
Doo::loadClass('PasswordHash');

/**
 * 用户表
 */
class AUsers extends DooModel {

    public $uid;
    public $uemail;
    public $upass;
    public $intime;
    public $_table = 'jl_users';
    public $_primarykey = 'uid';
    public $_fields = array('uid', 'uemail', 'upass', 'intime');
    private $ph;

    public function __construct() {
	parent::setupModel(__CLASS__);
	$this->ph = new PasswordHash(8, FALSE);
    }

    public function createUser($email, $passwd) {
	$userArray = $this->getOne(array('where' => 'uemail=?', 'param' => array($email), 'asArray' => TRUE));
	if (isset($userArray['uid'])) {
	    return FALSE;
	}
	$this->uemail = $email;
	$this->upass = $this->ph->HashPassword($passwd);
	$this->intime = time();
	return $this->insert();
    }

    public function getRowAll() {
	return $this->find(array('asArray' => TRUE));
    }

}

?>