您是否知道在PHP中使用数据库?在进入框架之前,你一定要从那里开始.当您对PHP和数据库如何交互有基本的了解时,将其转换为像Zend这样的良好框架应该不会太困难.
Zend Framework手册对数据库的所有功能进行了全面的概述.
/ Insert//***我假设您通过控制器传递数据*/
class Application_Model_YourModelName extends Zend_Db_Table_Abstract {
private static $_instance = null;
protected $_name = 'YourModelName';
public static function getinstance() {
if (self::$_instance == null)
self::$_instance = new Application_Model_YourModelName();
return self::$_instance;
}
public function insertFunction(){
if(func_num_args()>0){
$userName = func_get_arg(0); // or some index if wanna pass through key value pair
$password = md5(func_get_arg(1));
$data = array('userName'=>$userName, 'password'=>$password);
$insert = $this->insert($data);
}
}
public function fetchFunction(){
$sql = $this->select()
->where("*Your condition*")
;
$result = $this->getAdapter->fetchAll(sql);
}
Run Code Online (Sandbox Code Playgroud)
在使用md5功能的安全方面是不够安全的,你可能想要寻找bcrypt哈希算法..这是相同的链接:http: //framework.zend.com/manual/current/en/modules/zend .crypt.password.html
归档时间: |
|
查看次数: |
365 次 |
最近记录: |