我有一个链接http://mywebsite.com/referral/dafa60b2b96c366e165be58649755742
带参数dafa60b2b96c366e165be58649755742
试图获取该参数以连接到数据库以获取该用户信息,但最终没有得到任何对象:注意:尝试获取非对象的属性......
这是我的代码:
应用程序.ini:
resources.router.routes.referralSelectProduct.route = "/referral/:url" resources.router.routes.referralSelectProduct.defaults.controller = 索引资源.router.routes.referralSelectProduct.defaults.action = 推荐-选择-产品资源.路由器.routes.referralSelectProduct.reqs.url = "[0-9a-zA-Z]+"
控制器:
public function referralSelectProductAction()
{
$referral_url = $this->getRequest()->getParam('url');
$user = $this->_helper->model('Users')->fetchRowByFields(array('url' => $referral_url));
setcookie('referral_url', $referral_url, time() + 3600*24*30, '/');
}
模型:
class Application_Model_DbTable_Users extends Sayka_Db_Table_Abstract{
protected $_rowClass = 'Application_Model_DbTable_Row_User';protected $_name = 'users';}
看法:
<div id="content_bottom" class="content"><br/>
<h1>Select the product to refer your friend <span class="colorset_orange"><?php echo $this->user()->first_name; ?></span>.</h1>
<div><a class="refer_submit" href="?email=<?php echo $this->user()->email ?>&first_name=<?php echo $this->user()->first_name; ?>&last_name=<?php echo $this->user()->last_name; ?>" id="btn_free_download">Free Download</a></div>
<div><a class="refer_submit" href="#" id="btn_buy_now">Buy Now</a></div>
我的观点最终在数据库中没有得到该用户的对象。