Codeigniter:在模型和控制器、模型和模型、控制器和控制器之间使用变量的最简单方法
难道这根本不可能吗?
我想我应该清理一些代码,并将数据库查询仅放入它们所属的模型中,并将属于控制器中的所有其他代码放入控制器中。
现在我不断收到未定义的变量错误。这不是问题,但我正在尝试找出如何在文件之间调用变量。
我只是想将注册时生成的随机哈希存储在变量中,因为这是我在发送到用户电子邮件的“单击此处激活帐户”链接的锚点中使用的变量。
我还在方法中使用相同的变量,将电子邮件中 URL 末尾的 uri 哈希与数据库中存储的 uri 哈希进行比较。以便用户确认其帐户并将数据库中的“状态”更新为 1 (活性)。
我真的很感激一些建议。我很享受这个学习过程。睡眠不足,但很享受它,因为它让我进行逻辑思考。
Is this just impossible?
I thought I would clean up some of my code and put db queries in models only where they belong and put all the other code that belongs in controllers in controllers.
Now I keep getting undefined variable errors. Which is not a problem but I'm trying to work out how to call variables between files.
I would simply like the random hash generated at registration .. stored in a variable because that's the variable I use in the anchor for the "click here to activate account" link that is sent to users email.
I also use that same variable in the method that compares the uri hash that's at the end of the URL in their email with the one stored in the database.. in order for user to confirm their account and update "status" in database to 1(activated).
I would really appreciate some advice. I'm enjoying this learning process. Loosing sleep but enjoying it as it make me think logically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果变量位于单独的文件中,则无法访问该变量,而应该在类中设置它。
You cannot access a variable if it's in a seperate file, instead you should set it in your class.