kohana-3

PHP shorthand syntax

你离开我真会死。 提交于 2019-12-02 03:04:21
I've just came across this on GitHub. ($config === NULL) and $config = Kohana::config('email'); Is that the equivalent of if ($config === NULL) { $config = Kohana::config('email'); } Is this commonplace? Would I expect other developers looking at my code if I used that first way to instantly know what it was doing? Took me a second to get it, but that should actually work in just about every programming language. Because the "and" or "or" operators are lazily evaluated, if the statement on the left is false, then there's no need to evaluate the rest of the statements because the whole

Kohana 3.2. - How can I use hyphens in URIs

為{幸葍}努か 提交于 2019-12-01 05:44:40
问题 Recently I've been doing some research into SEO and how URIs that use hyphens or underscores are treated differently, particularly by Google who view hyphens as separators. Anyway, eager to adapt my current project to meet this criteria I found that because Kohana uses function names to define pages I was receiving the unexpected '-' warning. I was wondering whether there was any way to enable the use of URIs in Kohana like: http://www.mysite.com/controller/function-name Obviously I could

PHP: What does __('Some text') do?

让人想犯罪 __ 提交于 2019-11-30 10:52:21
问题 Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome To Acme Widgets'); What does __('Text') mean? What is it? What does it do? 回答1: In Kohana (version 3) the function is defined in system/base.php and is a convenience function to aid (as the other answers have mentioned) internationalization. You provide a string (with, optionally, some placeholders to substitute values into the finished text) which is then interpreted and, if required

PHP: What does __('Some text') do?

醉酒当歌 提交于 2019-11-29 22:46:01
Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome To Acme Widgets'); What does __('Text') mean? What is it? What does it do? In Kohana (version 3) the function is defined in system/base.php and is a convenience function to aid (as the other answers have mentioned) internationalization. You provide a string (with, optionally, some placeholders to substitute values into the finished text) which is then interpreted and, if required, a translation is returned. Contrary to assumptions in other answers, this does not use gettext . A very

Favourite Kohana Tips & Features? [closed]

陌路散爱 提交于 2019-11-29 18:35:46
Inspired from the other community wikis, I'm interested in hearing about the lesser known Kohana tips, tricks and features. Please, include only one tip per answer. Add Kohana versions if necessary. This is a community wiki . Kemo Generating Form::select() options from database result Kohana 3.1 and 3.0 $options = ORM::factory('model') ->order_by('title','ASC') ->find_all() ->as_array('id','title'); $select = Form::select('name', $options); It should be noted this is not restricted to the ORM and can be used on all database results (they all support as_array). See the database results

multi insert in kohana orm3

Deadly 提交于 2019-11-29 12:02:52
In my application i have a loop that executes about 1000 times, inside it i'm creating object and saving it. This is the part of application where i populate my database with data. In common this looks like this: foreach(...){ ... try{ $object = new Model_Whatever; $object->whatever=$whatever; $object->save();} catch(Exception $e){ ...} } } This produces 1000 of INSERT queries. Is it possible to, in some way, made kohana produce multi inserts. Split this into 10 inserts with 100 data sets in each. Is it possible and if yes that what is the way doing so? Whilst the Kohana ORM doesn't support

Favourite Kohana Tips & Features? [closed]

泄露秘密 提交于 2019-11-28 13:11:04
问题 Inspired from the other community wikis, I'm interested in hearing about the lesser known Kohana tips, tricks and features. Please, include only one tip per answer. Add Kohana versions if necessary. This is a community wiki . 回答1: Generating Form::select() options from database result Kohana 3.1 and 3.0 $options = ORM::factory('model') ->order_by('title','ASC') ->find_all() ->as_array('id','title'); $select = Form::select('name', $options); It should be noted this is not restricted to the ORM

Kohana 3 ORM: How to perform query with 2 many to many relationships

最后都变了- 提交于 2019-11-28 13:01:53
I have a products model with 2 many to many relationships defined. protected $_has_many = array ( 'foodcats' => array('model' => 'foodcat', 'through' => 'products_foodcats'), 'foodgroups' => array('model' => 'foodgroup', 'through' => 'products_foodgroups') ) I need a query where I find products with a given foodcat id and a given foodgroup name. I know I can do the following to get all products with a given foodcat id $foodcat = ORM::factory('foodcat',$foodCatId); $products = $foodcat->products->find_all(); But how do I query for products in that foodcat that also are in the foodgroup 'Entrees

TCPDF HTML with Special Characters displays empty PDF file

落花浮王杯 提交于 2019-11-28 08:30:31
I am using TCPDF Library Version: 5.9.011. I am trying to execute HTML layout as PDF. For which I tried with example provide with the site $html = '<h1>HTML Example</h1> <h2>List</h2> Some special characters: < € € € & è è © > \\slash \\\\double-slash \\\\\\triple-slash '; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); //Close and output PDF document $pdf->Output('example_006.pdf', 'I'); Apparently found that generated PDF only default header and footer with middle content blank. However if I remove special characters like: $html = '<h1>HTML Example</h1> <h2

multi insert in kohana orm3

喜夏-厌秋 提交于 2019-11-28 06:15:45
问题 In my application i have a loop that executes about 1000 times, inside it i'm creating object and saving it. This is the part of application where i populate my database with data. In common this looks like this: foreach(...){ ... try{ $object = new Model_Whatever; $object->whatever=$whatever; $object->save();} catch(Exception $e){ ...} } } This produces 1000 of INSERT queries. Is it possible to, in some way, made kohana produce multi inserts. Split this into 10 inserts with 100 data sets in