kohana

Recursively check the parents of a child in a database

旧城冷巷雨未停 提交于 2019-12-21 06:28:08
问题 I'm working on a CMS system that receives urls like this: /parent1/parent2/child/ Now it's easy to check only the child but in my opinion you should also check if the parents are correct and in the right order. The problem is that I'm unsure on how to do this. I'm using mysql. this is how that table would look: CREATE TABLE IF NOT EXISTS `pages` ( `id` int(11) NOT NULL auto_increment, `parent` int(11) NOT NULL default '0', `title` varchar(255) NOT NULL, `deleted` tinyint(1) NOT NULL default

Custom Exception Handling in Kohana3

亡梦爱人 提交于 2019-12-21 02:40:15
问题 I have a requirement to create custom exception for the exceptions generated by my app/module. I want to consolidate all the exception classes in one place and handle the exceptions in one place. I might have generic exceptions, like mentioned below, which I would like in one common place input invalid internal error (database errors, smtp errors, other failures) permission denied session error I might have specific exceptions, like mentioned below email not valid, etc. Specific exceptions

i18n and Error messages in Kohana 3

梦想与她 提交于 2019-12-20 14:59:29
问题 I am developping an administration application with Kohana 3 and I'm obviously working with a lot of forms. The application needs to be multilangual and I'm very confused about how to manage my messages files and especially how to access them. Does i18n support different folders and files inside the language folder? E.g: i18n en form fr form Or does it support arrays in the language file? i18n/fr.php <?php defined('SYSPATH') or die('No direct script access.'); return array ( 'common_form' =>

Using $this, self::, parent:: for code readability

风流意气都作罢 提交于 2019-12-20 12:34:07
问题 I would like to know if it is acceptable/preferred to use self::method() and parent::method() when working in php classes. You can use $this->method() but $this-> can also refer to a class variable, a parent class variable, or a method from the parent class. There is no ambiguity in self:: Is self:: depreciated and/or are there any caveats or cons to using this style? I understand that self:: and parent:: refer to a static instance of the class, but in kohana, unless you specifically define a

Kohana 3 get current controller/action/arguments

我是研究僧i 提交于 2019-12-20 10:11:15
问题 In Kohana 2 you could easily get that information like this: echo router::$controller; echo router::$method; echo router::$arguments[0-x]; Any idea how that works in Kohana 3? Thanks in advance! 回答1: From inside a controller: $this->request->controller $this->request->action $this->request->param('paramname') Unlike K2 arguments in K3 are accessed via kays which you define in your routes. Take for example this url: Route::set('default', '(<controller>(/<action>(/<id>)))') ->defaults(array(

Getting Error 324 (net::ERR_EMPTY_RESPONSE). when using memcache in kohana

拈花ヽ惹草 提交于 2019-12-19 19:44:39
问题 i'm getting this error when i try to use memcache using kohana. all i did was changed the hostname in the configuration file and used $cache = Cache::instance('memcache'); . i can telnet my memcached servers so probably the problem is not there. any help? 回答1: The error described is a Google Chrome error. This suggests that Kohana is not responding with anything, most likely because the error/exception handling is being suppressed. Check that PHP error_reporting is on ( E_ALL is a good value)

What version of Kohana am I using?

牧云@^-^@ 提交于 2019-12-19 16:54:17
问题 Where in the Kohana framework can I find out the version information? Everything I look at in the tutorials opposes to what I view in my application. I believe this to be a version issue as the methods and calls are slightly different between the documentation and my install. 回答1: At least for versions >= 3.0, the version number for Kohana is located in system/classes/kohana/core.php . It will be in this form: // Release version and codename const VERSION = '3.2.0'; Since that's just a

output image in a Kohana 3.2 view

烂漫一生 提交于 2019-12-19 10:17:54
问题 I have the following script to output an image to the browser wich works fine. $file_to_output=$_SERVER['DOCUMENT_ROOT'].'/static/imgs/uploads/20110318172207_16.jpg'; header('Content-Type: image/jpeg'); $raw=imagecreatefromjpeg($file_to_output); // Output the image imagejpeg($raw); // Free up memory imagedestroy($raw); when I put this exact same code in a view its doesn't work anymore and give a bunch of stange characters like this: ����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62),

kohana transaction with orm

旧时模样 提交于 2019-12-18 16:48:11
问题 is it possible (how) to use mysql transactions and rollbacks using kohana ORM ? 回答1: SQL Transactions in Kohana 3.x are not done the same way as in 2.x. In 3.x, the database class comes with transaction methods: $db->begin(); $db->commit(); $db->rollback(); This also works if you are using ORM stuff. Just initiate the transaction before ORM saves, updates, a or deletes. Read more in this post: http://dev.strategystar.net/2011/10/sql-transactions-with-kohana-3-x/ In 2.x, transactions had to be

Kohana 3.1 - The system does not load email module

霸气de小男生 提交于 2019-12-13 20:08:28
问题 I have a problem using Kohana 3.1. I add the old banks kohana-email module but the result is a error like this: ErrorException [ Fatal Error ]: Class 'Email' not found My application bootstrap.php file is like this: Kohana::modules(array( 'user' => MODPATH.'user', // Useradmin module 'auth' => MODPATH.'auth', // Basic authentication // 'cache' => MODPATH.'cache', // Caching with multiple backends // 'codebench' => MODPATH.'codebench', // Benchmarking tool 'database' => MODPATH.'database', //