Because the kohana framework has fewer users in China, and the new version is too different from kohana2. Recently I switched to kohana3 development (kohana3.1.0 stable version), so I took this opportunity to carefully read the official information. I benefited a lot, so I shared it with everyone through my personal website. Today, I will talk about the routing settings of kohana. .
Let me say it again, I am using ko3.1.0 which is different from ko3.
In fact, the routing setting of kohana3 is very simple. Open bootstrap.php under the application file, find Route::set, and you will see the following default route:
This is the default route. You can see that its composition is like this. Name, controller, action, parameters. It is particularly important to point out that each route must specify the default control and action. Generally, is index.
How to create a custom route? In fact, it is the same as the default writing method, except that you add what you want to add. For example, if there is a product list page, you need to get the ID of the product type and the current page number.
Routing can be set like this
Here, the first product is the name, and the following is the key point. Product is the controller, and /action is the action. It must be written like this. The following (/<>) are the parameters. On the page The way to get this parameter is like this, $id = $this->request->param('id'), the id in this must be the same as the id name in the route.
Students who need it can refer to this example to modify it, and it should be fine. I highly recommend everyone to read the two sites
1.http://kohanaframework.org/3.1/guide (official online documentation)
2. http://kerkness.ca/wiki/doku.php (unofficial wiki, the examples are better than the official one, but version 3.0)
You can compare and see, I believe everyone can play kohana, come on!!
not found MODPATH\\database\\classes\\kohana\\db.php [ 63 ] 58 * @param Please indicate how you call database or ORM in the process. It may be that the method you call is wrong. .
Normally I don't speak either. Today I’ll write a code for you to see: Simple Model layer
product.class.php:
class product{
public function getAllProducts(){
$q= "SELECT * FROM Product";
$r=$db->query($q);
$proArr=array();
while($row=db->fetchAssoc($r )){
$proArr[]=$row;
}
return $proArr;
}
}
?>
View and control layer:
getallproducts.php:
$product=new product();
$ps=$product->getAllProducts();
foreach($ps as $p ){
//Output the
found in the database echo $p['name'];
}
This is how I usually write PHP. When programming with arrays,
most of them output SQL statements and nest HTML in the page, which makes the page bloated and difficult to maintain and expand.
It is easier to modify after layering in this way