kohana-orm

Kohana 3.1 ORM: How to make 'where … in' clause

非 Y 不嫁゛ 提交于 2020-02-14 01:13:43
问题 Thanks to Kohana's excellent documentation, I'm having to resort to prostrate myself on SO. ;) Hopefully this is really simple: I'm trying to gather all stories which belong to a certain group of IDs. My code is as follows: $story_ids = '(12,56,99,213,319)'; $stories = ORM::factory('story')->where('id', 'IN', $story_ids)->find_all(); However, this is obviously not working. I'm getting a MySQL error because single-quotes are being put around the $story_ids string in the query. EDIT: I've also

Kohana 3.1 ORM: How to make 'where … in' clause

时光总嘲笑我的痴心妄想 提交于 2020-02-14 01:11:48
问题 Thanks to Kohana's excellent documentation, I'm having to resort to prostrate myself on SO. ;) Hopefully this is really simple: I'm trying to gather all stories which belong to a certain group of IDs. My code is as follows: $story_ids = '(12,56,99,213,319)'; $stories = ORM::factory('story')->where('id', 'IN', $story_ids)->find_all(); However, this is obviously not working. I'm getting a MySQL error because single-quotes are being put around the $story_ids string in the query. EDIT: I've also

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

北城以北 提交于 2020-02-05 10:58:50
问题 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( 'not_empty' => NULL, 'min_length' => array(5), 'max_length' => array(30), ), 'password_confirm' => array( 'matches' => array('password'), ), ); } class Model_UserAdmin extends Model_User { protected $_rules = array( 'username' => array( 'not

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

时间秒杀一切 提交于 2020-02-05 10:58:41
问题 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( 'not_empty' => NULL, 'min_length' => array(5), 'max_length' => array(30), ), 'password_confirm' => array( 'matches' => array('password'), ), ); } class Model_UserAdmin extends Model_User { protected $_rules = array( 'username' => array( 'not

Kohana ORM - Incorrect table name

一笑奈何 提交于 2020-01-06 08:23:08
问题 I have a weird problem with the Kohana (3.2) ORM query builder and i can't figure out what is wrong. I get "Incorrect table name" exception: Database_Exception [ 1103 ]: Incorrect table name '' [ SELECT ``.* FROM `` JOIN `user_plugins` ON (`user_plugins`.`plugin_id` = ``.`id`) WHERE `user_plugins`.`user_id` = '9' ] As you can see the table is empty in the query. Controller: $user = ORM::factory('user', Auth::instance()->get_user()->id); if ($user->loaded() ) { $result = $user->plugin->find

Kohana ORM - Incorrect table name

穿精又带淫゛_ 提交于 2020-01-06 08:23:05
问题 I have a weird problem with the Kohana (3.2) ORM query builder and i can't figure out what is wrong. I get "Incorrect table name" exception: Database_Exception [ 1103 ]: Incorrect table name '' [ SELECT ``.* FROM `` JOIN `user_plugins` ON (`user_plugins`.`plugin_id` = ``.`id`) WHERE `user_plugins`.`user_id` = '9' ] As you can see the table is empty in the query. Controller: $user = ORM::factory('user', Auth::instance()->get_user()->id); if ($user->loaded() ) { $result = $user->plugin->find

kohana columns introspection

ε祈祈猫儿з 提交于 2019-12-25 02:22:22
问题 I would like to know which is the functionality of the $_table_columns array on a KOHANA model. I ask this since the table's columns are loaded by introspection, what is the use of this array, is it for default values to the properties? 回答1: $_table_columns reflects your table column structure. So if your table has 3 columns (id, name, desc), $_table_columns will be setup to array('id' => '', 'name' => '', 'desc' => '') . By default $_table_columns is an empty array. When you extend ORM with

Kohana 3.3 ORM Validation - unique value not working when value is empty

≡放荡痞女 提交于 2019-12-25 02:14:33
问题 In a Model_Page class, extending the Kohana ORM class, I have this rules definition : public function rules() { return array( 'url' => array( array('Model_Page::unique_url', array($this)), ), ); } To simplify here, I will just return false from this function, so it should never validate when I try to save/update a page : public static function unique_url($page) { return false; } This works as expected, if the value for url is not NULL or not an empty string . But if I already have a page with

Tables not joining in Kohana 3.1 ORM

旧城冷巷雨未停 提交于 2019-12-23 13:00:54
问题 How do I get this to work? $stuff = ORM::factory('mytable') ->with('user') ->with('other_stuff') ->find_all(); I've got all of my relationships set up and everything seems to be working when I do other queries. However, in the query above it is not joining table users to mytable . I think it may be because there can be many users for one mytable. In the reference there is a method called join() which I think I might need to use here, but they don't give any information on it, and the stuff I

How to apply the “matches” validation rule in Kohana 3.1?

南笙酒味 提交于 2019-12-22 12:27:22
问题 I need to know how to apply the "matches" validation rule in Kohana 3.1. I've tried the following rule in my model with no success: 'password_confirm' => array( array('matches', array(':validation', ':field', 'password')), ) But it always fails. I put a var_dump($array) in the first line of the Valid::matches() method. I paste it below: /** * Checks if a field matches the value of another field. * * @param array array of values * @param string field name * @param string field name to match *