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...
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}]+...
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...
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...
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...
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 (...
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.
...
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 ...
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 ...
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 ...
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...
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();
...
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()
{
...
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...
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(
...
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?
...
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?
...
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, ...
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...
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...