kohana

Kohana — Command Line

假装没事ソ 提交于 2019-12-04 19:23:23
问题 I'm trying to "faux-fork" a process (an email being sent via SMTP) in my web application, and the application is built on Kohana. $command = 'test/email'; exec('php index.php '.$command.' > /dev/null/ &', $errors, $response); I'm getting an error -- Notice: Undefined index: SERVER_NAME When I look into Kohana's index.php file, I see that it is looking for a variable named SERVER_NAME, but I guess it is coming up NULL because Kohana couldn't detect this value and set it prior to run. Any ideas

In Kohana, can you trigger a 404 error?

こ雲淡風輕ζ 提交于 2019-12-04 18:39:07
问题 I have a controller called articles , which creates the articles model which gets the relevant data from the database. I want to, if the method I call returns false , to trigger a 404 error. This is what I have so far. $articleName = $this->uri->segment('articles'); $article = new Articles_Model(); $data = $article->getArticleUsingSlug($articleName); if (!$data) { Kohana::show_404; // This doesn't work. } I just added my own custom hook which redirects the user to an actual 404 (/articles

Should a two-to-many data relationship be treated as many-to-many?

 ̄綄美尐妖づ 提交于 2019-12-04 12:36:51
I have 2 database tables: Teams and Games. For the purpose of this question, we are dealing with football (soccer) teams and games. Each Game has exactly 2 teams, generally a home team and an away team although occasionally both teams can be neutral. My question is whether I should represent this data relationship using 2 foreign keys in the Games table (home_team_id, away_team_id) or whether I should use a many-to-many relationship with a games_teams table to link the two, in which case I would need to also store whether the team was the home or away team and seems a little overkill. To add

Kohana 3 pagination

霸气de小男生 提交于 2019-12-04 12:11:53
问题 I'm really lost on how pagination works in kohana 3. Is there a good example of pagination in Kohana 3 anywhere? 回答1: // Get the total count of articles $count = $this ->_profil ->articles ->count_all(); // Create the pagination object $pagi = Pagination::factory(array( 'items_per_page' => 4, 'total_items' => $count, )); // Find actual articles $articles = $this->_profil ->articles ->join_categories() ->order_by('id','DESC') ->limit($pagi->items_per_page) ->offset($pagi->offset) ->find_all();

Independent getter/setter methods, or combined?

雨燕双飞 提交于 2019-12-04 10:23:12
问题 While working on a project, I've been making some changes and browsing around existing framework API docs for insight. While perusing the Kohana docs, I noticed that the getters/setters of any given class are typically combined: public function someProperty($value = null){ if(is_null($value){ return $this->_someProperty; } $this->_someProperty = $value; return $this; } Rather than: public function setSomeProperty($value){ $this->_someProperty = $value; return $this; } public function

Why use a templating engine with a framework?

♀尐吖头ヾ 提交于 2019-12-04 09:55:47
问题 I recently discovered the PHP framework Kohana (which is awesome) and was reading a thread about using it in conjunction with a templating engine such as Smarty or Twig. My question is why bother? Surely an MVC framework, by definition, is a templating engine. Even "raw" PHP is, arguably, a templating engine. What possible benefits are there of adding another level of abstraction on top of what's already present in a framework such as Kohana? EDIT - I realise that an MVC framework isn't the

How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

三世轮回 提交于 2019-12-04 06:43:47
问题 I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing. <?php Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings')) ->defaults(array( 'directory' => 'settings', 'controller' => 'settings', 'action' => 'index', )); ?> So, this is my directory structure for "Settings" use case: - ..\application

default timezone error in php

我们两清 提交于 2019-12-04 05:07:10
问题 I got the following error/warning while tring to install Kohana/SilverStripe. What does it mean and What do I do for it? Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead

Architecture: API as core for a website & mobile-app

依然范特西╮ 提交于 2019-12-04 05:04:02
I have different questions about a full architecture idea. I hope someone with great experience could help me out because I am pretty much getting stuck in all possibilities. I'm planning to rewrite a community website. Our customer wants to make use of native mobile apps in the future. So I will need to take this into account. Because of this I have decided to create a 100% REST API architecture based on the PHP framework Kohana. I have choosen Kohana because this makes scaling the internal API to a other server very easily without much extra effort. (Kohana threats internal url requests not

Recursively check the parents of a child in a database

て烟熏妆下的殇ゞ 提交于 2019-12-03 21:22:37
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 '0', PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; the parent field keeps