kohana-3

How do I build a UNION query with ORDER BY and GROUP BY in Kohana's query builder?

一世执手 提交于 2019-12-10 16:26:44
问题 I'm trying to build a UNION query using Kohana's query builder. Everything works fine until I add a GROUP BY or ORDER BY clause. Here is the code I'm using (simplified): $query1 = DB::select('p.name') ->from(array('person', 'p')) ->where('p.organization', 'LIKE', 'foo%') ->limit(10); $names = DB::select('sh.name') ->union($query1, FALSE) ->from(array('stakeholder', 'sh')) ->where('sh.organization', 'LIKE', 'foo%') ->group_by('name') ->order_by('name') ->limit(10) ->execute() ->as_array();

kohana 3.2 ORM find_all() with relationships

為{幸葍}努か 提交于 2019-12-10 12:12:58
问题 I have 3 tables: artists{id,name} media{id,name,filename} media_artists{artist_id,media_id} I created the models with n-n relationships as described in the Kohana guide. When I do in a controller: $artist_view = new View('artists/profile'); $artist_id = $this->request->param('id'); $artist_view->artists = $artist_model->where('id', '=', $artist_id)->find(); $artist_view->media = $artist_model->media->find_all(); it works fine, and I can call the media entries related to this specific artist

Kohana 3.3 Not working from Subdirectory

百般思念 提交于 2019-12-10 11:01:47
问题 Answer: Kohana 3.3, they didn't take into account case-sensitivity on folders/files (they capitalized some directories/files) so this is going to drive some folks nuts when they start switching to the new Kohana (just like I did). I switched back to Kohana 3.2 until this has been fixed. Thank you very much for taking time in reading my huge post I had about this silly problem, and I hope this answer saves a poor souls life in the future =) 回答1: It is not correct that "they didn't take into

Need assistance with Kohana 3 and catch all route turning into a 404 error

半世苍凉 提交于 2019-12-10 00:43:02
问题 Based on this documentation, I've implemented a catch all route which routes to an error page. Here is the last route in my bootstrap.php Route::set('default', '<path>', array('path' => '.+')) ->defaults(array( 'controller' => 'errors', 'action' => '404', )); However I keep getting this exception thrown when I try and go to a non existent page Kohana_Exception [ 0 ]: Required route parameter not passed: path If I make the <path> segment optional (i.e. wrap it in parenthesis) then it just

how to manage multiple templates and template assets

微笑、不失礼 提交于 2019-12-09 13:51:39
问题 I am totally newbie with Kohana and have been reading Docs, tutorials and forum posts to know how it works. I am trying to implement this framework on one of my application and now I am stuck at managing multiple templates and it's assets. Basically my application will have a templates folders like template1, template2 .... and all the images, css, js related with particular template needs to contain within the template folder. So is it possible to have such implementations? If so how can I

How to integrate Wordpress into Kohana 3

做~自己de王妃 提交于 2019-12-08 23:13:17
问题 I now need to make a Kohana 3 site have a Wordpress blog. I've seen Kerkness' Kohana For Wordpress, but it seems to be the opposite of what I want. Here are the options I have thought of Style a template to look exactly like the Kohana site (time consuming, non DRY and may not work) Include the blog within an iframe (ugly as all hell) cURL the Wordpress pages in. This of course means I will need to create layers between comment posting, etc, which sounds like too much work. Is there any way I

What should I do with Kohana 3 to make route actions' hyphens change to underscores?

老子叫甜甜 提交于 2019-12-08 21:22:44
Consider this route in bootstrap.php ... Route::set('crud', 'staff/<controller>(/<action>(/<id>))', array( 'controller' => '(activities|users|default-emails)', 'action' => '(new|view|modify|delete)', 'id' => '\d+' ))->defaults(array( 'directory' => 'staff', 'action' => 'view' )); The default-emails is trying to run the action_default-emails() method which obviously doesn't and can't exist. What part of Kohana should I extend to map that hyphen into a underscore internally? Should I be concerned that if I do do this, then it will be accessible via both _ and - delimited routes? Thanks. The

When using Kohana DB, how does one avoid duplicate code when needing a count for pagination?

南楼画角 提交于 2019-12-08 08:30:49
问题 Using the Kohana query builder, is it possible to build my query piece by piece. Then execute a count on said query. Then execute the query itself. All without having to write duplicate conditionals... one for the count and one for the results... Adding DB::select(array('COUNT("pid")', 'mycount')) To the main query results in only getting back one record. Is it maybe possible to execute the count, and somehow remove array('COUNT("pid")', 'mycount') from the select... Right now the only way I

In Kohana 3, how do you figure out errors made during a query?

旧巷老猫 提交于 2019-12-08 04:18:46
问题 I'm using Kohana 3. I'm writing an update query, and it is working for everything except this one section. If I do a var_dump() on the results of $db->execute() I get either a 1 or 0 to say it failed or not. It is failing in this example (returning 0). How can I figure out what error is happening? It justs seems to be silenty failing at the time being. I tried doing echo mysql_error() but it didn't work, as I expected, as Kohana 3's db library uses PDO I'm pretty sure. How can I figure out

Class not found exception - Making a Helper on Kohana 3.1

强颜欢笑 提交于 2019-12-07 16:29:13
问题 got a fresh install of Kohana 3.1. Trying to make my own helpers. I have created a helper in the application/classes/helpers/ directory. I have called the file javascript.php, the class is called Helper_Javascript and has a static function that just returns "alert('sometext')" here it is class Helper_Javascript { public static function alert($message) { return "alert('$message');\n"; } } The problem is in my view or controller when I try to use the helper i just kepp getting the Class not