1. 用户登录验证流程
users controller : beforefilter
-> app controller : beforefilter
-> auth component : startup
-> auth component : login
-> auth component : admin_login
->render view template for login
->press submit, post form data to controller, repeat the above process again.
2. 取消关联查询
You can use recursive or unbind whenever you want to unbind associations from models. This is very useful because there are cases when you want to execute a simple query and you do not want to join other tables. Here comes unbind. Unbind allows us to unbind all but some model associations. On the other hand if you want to unbind all associations you can use recursive like this:
读取参数
http://book.cakephp.org/view/55/The-Parameters-Attribute-params
$this->params['url']
Stores the current URL requested, along with key-value pairs of get variables. For example, if the URL /posts/view/?var1=3&var2=4 was called, $this->params['url']
would contain:
[url] => Array ( [url] => posts/view [var1] => 3 [var2] => 4 )
设置参数
http://book.cakephp.org/view/1448/url
URL with GET params and named anchor
Plain Text View
<?php echo $this->Html->url(array( "controller" => "posts", "action" => "search", "?" => array("foo" => "bar"), "#" => "first")); ?> //Output /posts/search?foo=bar#first
<?php echo $this->Html->url(array(
"controller" => "posts",
"action" => "search",
"?" => array("foo" => "bar"),
"#" => "first"));
?>
//Output
/posts/search?foo=bar#first
5. how to get current url in view
if you want to take current URL in cakePHP view than check out below code :
echo Router::url($this->here, true);
This will output current URL. If you want relative path and not full URL than you can do like this :
echo $this->here;
By this you can get relative path in the view.
6. how to get domain name
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i", windows.location, $matches);
$host = $matches[2];