kohana

How to get your data from a select statement in Kohana?

If I have this code (which is from their docs) $query = DB::query(Database::SELECT, 'SELECT * FROM users WHERE username = :user'); $query->param(':user', 'john'); $query->execute(); How would I access the actual data returned from this? I am looking for an associate array containing $array['username'] and whatever other columns are o...

Regex as first line of defense against XSS

I had a regex as the first line of defense against XSS. public static function standard_text($str) { // pL matches letters // pN matches numbers // pZ matches whitespace // pPc matches underscores // pPd matches dashes // pPo matches normal puncuation return (bool) preg_match('/^[\pL\pN\pZ\p{Pc}\p{Pd}\p{Po}]+...

How should I organize source control for framework-based projects?

I'm struggling trying to sort out what the best-practice is for putting a project under source control when the project is written against a framework. In my situation I will be using Mercurial for source control. Most PHP frameworks have an 'application' folder where I'm supposed to put my code that interacts with the framework. So i...

Can I format my validation strings with relevant info in Kohana 3?

I've noticed in Kohana 3 these error messages provided by default. return array( 'not_empty' => ':field must not be empty.', ); Obviously, :field is replaced with the field name. Now I am validating an image upload. Obviously, I'm allowing only JPG, JPEG, GIF & PNG. I have an error message set up like so. return array( 'pho...

Using 'and' with Kohana Jelly

I am counting how many rows there are in a database that match two conditions $rows = Jelly::select('brief')->where('creator_id', '=', $this->view->user->id, 'and', 'name', '=', $name)->count(); I have done this before a long time ago and have forgotten how. I was wondering if this is the correct way of doing it. I just can't seem to...

How to get Kohana base_url in template

In Kohana 3 bootstrap.php one can define base_url: Kohana::init(array( 'base_url' => '/foo/', )); This usually means also moving the /js/, /css/ and other media to that base dir like /foo/js/, /foo/css/. My question is not to discuss good or bad of such. Is there a built-in way in Kohana to access the base_url from a template (...

Kohana Development Cycle

I was wondering if users that are using Kohana primarily to explain how they go from planing to deployment in Kohana. Why do you use Kohana instead of the other frameworks that you tried. ...

PHP framework with good user login/admin

I am looking for a good PHP framework with a good user login & admin. I have looked at Codeigniter, but the user admins I have found seem dated. I have been looking at at Kohana, but have not been able to find a viable login / admin pannel? I basically need: User login User verification of new user User p/w reset Admin add/edit/del ...

Kohana persistant sessions and sub-domains

I am using the database session driver in Kohana v2. To make sessions persistent, Kohana creates a token cookie. This cookie uses the cookie configuration I suppose. When I set a session like this: $this->session->set('UserID', $user->UserID); The session variable UserID is availble even when the browser is closed. Nice. The cookie ...

"WHERE column IS NOT NULL" with Kohana v3 Query Builder

Is it possible with Kohana v3 Query Builder (Kohana v3 being possibly the most poorly documented #$@$%...) to use the IS NOT NULL operator? The where($column, $op, $value) method requires all three parameters and even if I specify ->where('col', 'IS NOT NULL', '') it builds and invalid query eg. SELECT * FROM table WHERE col IS NOT ...

Handling Forms with Relations in Kohana/MVC

This is a question I had about working with the Kohana framework, though I imagine that this is something that could apply to MVC frameworks in general. Let's say I have 2 objects/models, an animal object and a farm object, where an animal belongs to a farm, and a farm has many animals. I have a form for creating new animals, and I want...

Can I save new related objects via reference without copying id's manually in Kohana 3's ORM?

I have 2 objects. Player and Match. Player is a child of Match. I want to know if I can create both of these at the same time without inserting id's manually. i.e. $match = ORM::factory('match'); $player1 = ORM::factory('player'); $player2 = ORM::factory('player'); $player1->match = $match; $player2->match = $match; $match->save(); ...

php bind data explanation (possibly kohana specific?)

Hi, Attempting to dive in to Kohana and I'm reading the Unofficial 3.0 Kohana wiki as it's more user friendly than the user docs atm imo. It mentions "Binding Data to a View", like so: <?php defined('SYSPATH') or die('No direct script access.'); class Controller_Welcome extends Controller { public function action_index() { ...

How do I set columns/members in Kohana ORM v3

class Model_User extends ORM { // columns: UserID, Name // public $Name ; // this didn't work } Currently I create an object: $user = new Model_User() ; and access columns like: $user->Name = 'My Name'; I'd like to have my IDE show me all the columns in the data model to avoid misspellings and to now right away what fields I ca...

Is there a way to override Model properties without defining them all again with Kohana?

I have the following, for example: class Model_User extends ORM { protected $_rules = array( 'username' => array( 'not_empty' => NULL, 'min_length' => array(6), 'max_length' => array(250), 'regex' => array('/^[-\pL\pN_@.]++$/uD'), ), 'password' => array( ...

Order results from Kohana ORM

I'm using Kohana's ORM library, and I'm wondering if there is any way to order the results that are generated. Example: $priorities = ORM::factory('priority')->select_list('id','label'); //how to order these? ...

Kohana v3 ORM Select and Where clause based on different table.

Hi I need to do something like this: $hours->task->job->where('group_id' , '=' , $num)->find_all(); This would return job information. Is there any way to tell orm to return the information from the $hours table instead? ...

Kohana 3: getting related data from an ORM model

When using Kohana 3's ORM models, what is the best way to get data from fields of related models? For example, I have an employee, who has one company, and has many assignments. How would I go about getting data from fields in the company model and assignment model(s) (i.e. in a has_one and a has_many relationship)? EDIT: as requested, ...

Kohana 2.3.4 ORM - delete pivot table relationships

I'm trying to remove relationships from a pivot table with ORM's remove method. This is for an edit method that updates the categories associated with a product. I can successfully add multiple relationships, but I need to remove those relationships prior to adding them again. Here's how I add them foreach ($categories as $a...

Kohana 3 form select validation

Hay all, I am trying to validate a select in kohana 3.0 and I am using the necessary rules. However the validation does no "kick in" when the user does not make a selection. <select id="discipline" name="discipline" > <option value="0"> -- Select One -- </option> <option value="-2">Information Technology and Engineering</option> <optio...