Kohana's config files look like this.. here is an example of a database config file (simplified)
return array(
'dbhost' => 'localhost',
'user' => 'Tom_Jones'
);
I've also got a CMS which wants the connection details. Whilst the CMS uses a different user (with more rights), I'd like to know the best way to include this file a...
In Kohana 3, I can bind a param in a query like so
$query = 'SELECT name FROM users WHERE id = :id';
This is neat, but sometimes I want other things to be configurable, like the table name. When I use a named param for table name, it fails. I have just been building the string in these circumstances.
My question is, how can I escape ...
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 ...
I've looked at how shadowhand (the main guy behind Kohana currently) set up his bootstrap.php file to handle exceptions on GitHub.
I thought, "that's cool", so I incorporated something similar.
However, instead of serving up a view, I'd like to send the request to a different route (or at least point it to a controller/action pair).
S...
I have been through a fair bit of the code in modules/database/classes/ but still have not found how to return the last insert Id.
How do I get this?
...
When I access my site on MAMP like so, it works great
localhost/site/about-us/
When I upload it to my remote server, and access it like this
http://www.server.com/site/about-us/
all requests go back to the 'default' set up in bootstrap.php.
Here is my route setting.
Route::set('default', '(<page>)')
->defaults(array(
...
the PHP framework I am using (Kohana) recently implemented the HMVC architecture. I have read that it's a layered mvc where requests are made on top of each other. It is a bit like ajax, just purely server-side. I have applied it a bit on some experiments but I can't apply it to any of my projects (because I can't find a need for it). Ha...
I need to quote a string a string in PHP using Kohana 3's Database library. In 2.3, all I had to do is $this->db->escape().
How can I do this in 3? I seem to remember seeing something like quote() when I was viewing the source, but for the life of me can I find it again.
...
I need to add some errors to the Validation helper in Kohana 3.
Here is what I start with:
// validate form
$post = Validate::factory($_POST)
// Trim all fields
->filter(TRUE, 'trim')
// Rules for name
->rule('first-name', 'not_empty')
->rule('last-nam...
Before I used a framework, I'd often define things like so (so my code makes more sense to read)
define('MINUTE', 60);
define('HOUR', MINUTE * 60); // etc
Is anything like this built into Kohana 3, or should I specify this myself (perhaps in bootstrap.php)?
...
I need to delete rows where a datetime field is over 2 weeks old.
This is what I have came up with
$duration = Date::WEEK * 2; // int(1209600)
$query = 'DELETE FROM properties
WHERE TIMEDIFF(' . date(DATE_ISO8601) . ', reserved_datetime) > ' . $duration;
I don't often write complicated queries (preferring to do stuff in P...
My logout function needs to update the latest row of a list of logins.
This is what I have came up with, however it doesn't even pass syntax validation.
$query =
'UPDATE user_logins
SET active = 0
WHERE user_id = ' . Database::instance()->escape($this->getCurrentUserId()) . '
AND datetime = MAX(datetime) LIMIT 1';
...
When I have a controller, e.g. article I often have a action_view() that handles most of the code.
Sometimes, it can become 80-100 lines long.
My controller usually handles all of these:
binding template variables
setting sessions (where appropriate)
sending emails
validating forms
I could see bit and pieces that I could make anoth...
I have used ver 2 before but i'm thinking of using ver 3 for my new project. Is it advisable to use ver 3 at this point event when it's not yet stable?
...
Hi. I meet kohana 3. I would like to know the answer to my question. In general, there are 4 url that I would like to handle one router.
Namely:
/ news /
/ news/11-02-2009 /
/ news / butik /
/ news/butik/11-02-2009 /
Where date 11/02/2009 News. Can be any correct date.
A butik a string [a-zA-Z_] +
I made such a router:
Rout...
Reading about Kohana templates and saw soemthing I've never seen before:
$this->template->title = __('Welcome To Acme Widgets');
What does __('Text') mean? What is it? What does it do?
...
Maybe not the best explanation, but hear me out. Say I have the following in a config file called menu.php:
// Default controller is 'home' and default action is 'index'
return array(
'items' => array(
'Home' => '',
'News' => 'news',
'Resources' => 'resources',
),
);
I now want to print this out as a menu, whic...
Say I have a file in my kohana 3 website called assets/somefile.jpg. I can get the url to that file by doing
echo Url::site('assets/somefile.jpg'); // /kohana/assets/somefile.jpg
Is there a way I can get the absolute path to that file? Like if I want to fopen it or get the size of the file or something like that.
In other words, I ...
I'm looking for advice, tutorials and links at how to set up a mid-sized web application with Kohana 3. I have implemented MVC patterns in the past but never worked against a "formalized" MVC framework so I'm still getting my head around the terminology - toying around with basic examples, building views and templates, and so on.
I'm pr...
I'm probably overlooking something really obvious here.
Comments are in to help explain any library specific code.
public function areCookiesEnabled() {
$random = 'cx67ds';
// set cookie
cookie::set('test_cookie', $random);
// try and get cookie, if not set to false
$testCookie = cookie::get('...