kohana-3

Kohana-v3 ORM parent relationship

Hi all, I just started with the version 3 of the Kohana Framework. I have worked a little with the $_has_many etc. Now I have the table pages. The primary key is pageID. The table has a column called parentPageID. Now I want to make a ORM model who, when accesed like this $page->parent->find() returns the page identified by parentPageI...

Problem connecting to postgres with Kohana 3 database module on OS X Snow Leopard

Edits/Additions at bottom... Environment: Mac OS X 10.6 Snow Leopard PHP 5.3 Kohana 3.0.4 When I try to configure and use a connection to a postgresql database on localhost I get the following error: ErrorException [ Warning ]: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)...

Kohana 3 get full site home url

Hello I have installed Kohana in kohana directory in my xampp public folder. When I try url::base(); I've got only /kohana/, but I want to http://localhost/kohana/ Any chance for get this by Kohana, or I must standard PHP? Regards ...

Include Custom Classes in Kohana 3 User Guide

I've been trying to figure out how to do this and I thought I'd share what I found on stackoverflow so that others looking for the same info can benefit. Specifically, i was trying to figure out how to enable the Kohana 3 User Guide in my application and to automatically include my custom code in the API guide that is built. I post...

Kohana 3 - Getting value from URL

I have log in functionality that will check for a session, if it not there the user will be redirected via Request::instance()->redirect('managers/error/1'); In the error action in the managers controller I can't get the value 1 which represents a specific error msg. How can I capture the value "1" from the url, I'm only using standard ...

Kohana 3 - Constructor

I attempted to use public function __construct() { } but got the error ErrorException [ Strict ]: Creating default object from empty value. The reason behind this is that I use a controller that is protected for logged in users only, I don't want to have to call $this->protect(); from every action in the controller. Hence my a...

Kohana 3 - Query builder gives 0 rows

The following query returns one row as expected when run from phpmyadmin. SELECT units . * , locations . * FROM units, locations WHERE units.id = '1' AND units.location_id = locations.id LIMIT 0 , 30 But when I try to do it in Kohana 3: $unit = DB::select('units.*', 'locations.*') ->from('units', 'locations') ->where('units.id', '...

Inheritance in kohana

Hi all, I have recently started to use Kohana and I know inheritance is in infancy stages at the moment. The work around is using a $_has_one annotation on the child class model. In may case i have "page" as the parent of "article". I have something like, protected $_has_one = array('mypage'=>array('model'=>'page', 'foreign_key'=>'id'))...

Kohana 3 - custom route

I'm trying to create a custom route like:search/result/city/p1/state/p2/zip/p3/min/p4/max/p5/bed/p6/bath/p7/cats/p8/dogs/p9/parking/p10 Where search is the controller and result the action p1-p10 are variables. ...

How to get root as '/' with Kohana3, base_url and mod rewrite.

Hi all! I've only just started using Kohana ( 3 hours ago), and so far it's blown my socks off (and I'm wearing slippers, so that's quite impressive). Right now, I have a controller 'Controller_FrontPage' with associated views and models and I'm trying to get it accesible from the root of my website (eg, http://www.mysite.com/). If I ...

Can I include a view in Kohana 3 that is not within `application/views`?

I am building a staff area for a website, which is completely different to the main brochure style site. I have 2 Kohana systems setup. I realise they can both share the same system and modules folder. Now, with the second one, I want to make the main template view a view in a different folder. I tried this in my base controller $thi...

Kohana 3: Auth module

Hi, i'm trying to learn the Kohana's Auth module but login method always return false. Controller: <?php defined('SYSPATH') OR die('No Direct Script Access'); class Controller_Auth extends Controller { public function action_index() { if($_POST) { $this->login(); } $this->template = View::factor...

Kohanav3 ORM: calling where->find_all twice

When I do something like the following: $site = ORM::factory('site')->where('name', '=', 'Test Site')->find(); $users = $site->users; $deletedusers = $users->where('deleted', '=', '1')->find_all(); $nondeletedusers = $users->where('deleted', '=', '0')->find_all(); The contents of $deletedusers is correct, but the $nondeletedusers cont...

Kohana newbie - sample CRUD application

I'm completely new to this framework and I'm trying to find some sample CRUD application to get started with Kohana 3. There is a tutorial and information in the unofficial Kohana 3 Wiki (http://kerkness.ca/wiki/doku.php), but event there, there are some aspects that are not covered (the model, validation, etc). ...

Kohana 3 ORM - grouping where conditions with parentheses

I'm trying to run a query through the ORM like this: SELECT * from table where (fname like 'string%' or lname like 'string%') AND (fname like 'string2%' or lname like 'string2%'); Here's what i have so far: $results = ORM::factory('profiles'); foreach ($strings as $string) { $result->where('fname', 'like', "$string%"); $r...

Log MySQL Query In Kohana 3

Hi All, I am using Kohana 3. I want to log the MySQL queries being executed by an application. The reason to determine the query of type INSERT,UPDATE and DELETE which are being executed in a process and store them in another MySQL table with date-time for further reference. Can anybody tell how can I achieve this? ...

Kohana 3 download file from another server

Hi All, I am using Kohana 3. Up to now my downloadable files were residing in my application document root. So far using $this->request->send_file($download_file); it was working perfectly right. But now my downloadable files are on another server can be accessed using http say http:://www.test.com/download/test1.doc. So Kohana's $thi...

DOMPDF: files with 0 bytes and text/plain mime-type

Hi, I'm using Kohana 3 and pdfview/DOMPDF to generate pdf files but they are generated with 0 bytes and text/plain mime-type. Controller: public function action_pdf() { if(isset($_POST['dados'])) { $pdf = View_PDF::factory('export/pdf'); $pdf->title = ''; $pdf->headers = array(); $pdf->data = array()...

How can I change the default database used in Kohana 3?

I've set up a new database config in application/config/database.php called staff. I've then made a new base model, and added a protected $db variable and set it in the constructor to $this->db = Database::instance('staff'). When I try and replace Db::query(Database::SELECT, $query) with $this->db->query(Database::SELECT, $query), it f...

creating distinct list using kohana

Is there a way to generate a distinct list in kohana controller ? function action_load($pid) { $v = View::factory('pages/registrationform'); $programme = ORM::factory('academicprogramme', $pid); if ($programme->loaded()) { $sid = $programme->mysubject->id; $v->subject = ORM::factory('subject')->find($sid); ...