kohana-orm

Helping Kohana 3 ORM to speed up a little

半世苍凉 提交于 2019-12-22 09:42:30
问题 I noticed that Kohana 3 ORM runs a "SHOW FULL COLUMNS" for each of my models when I start using them: SHOW FULL COLUMNS FROM `mytable` This query might take a few clock cycles to execute (in the Kohana profiler it's actually the slowest of all queries ran in my current app). Is there a way to help Kohana 3 ORM to speed up by disabling this behaviour and explicitly define the columns in my models instead? 回答1: biakaveron answered my question with a comment so I can't except the correct answer.

Kohana v3.1.0 ORM _ignored_columns — now that it's gone, what should I do instead?

百般思念 提交于 2019-12-22 08:52:56
问题 It seems that in v3.1.0 of Kohana's ORM that the _ignored_columns property has been removed. What the is the recommended technique to dealing with fields that aren't in the databases? The case I have right now is password_confirm where password is a field, but we require the user to enter their password twice. 回答1: You can pass an extra validation object to save, create and update. So your example would look like: /** * Password validation for plain passwords. * * @param array $values *

Kohana 3 auth module, getting users with 'staff' or 'manager' role

▼魔方 西西 提交于 2019-12-22 06:37:06
问题 I'm learning the framework, and now building an application using it. I need to get all users that have 'user' or 'staff' role, but I couldn't find about it on the documentation. Help anyone? (I think it's more an ORM problem the the auth module) 回答1: I didn't find an easy way to do this using the ORM, but I have a workaround. This is my code for anyone who might encounter the same problem with me. // One for each role $staffs = ORM::factory('role', array('name' => 'staff'))->users->find_all(

Kohana 3.3 ORM _has_many _belongs_to

不问归期 提交于 2019-12-20 07:39:11
问题 I am trying to set up a product object in Kohana 3.3 using the built in ORM. I want it so that when I call: $p1 = ORM::factory('product') ->where('product_type', '=', '1') ->find_all(); it will create an object of this structure: Model_Product Object ( [_long_list_of_kohana_properties] => Array () [_object:protected] => Array ( [id] => 2 [product_type] => 1 ... [product_attributes] => Array (List of attributes) ) ) Currently, it produces this: Model_Product Object ( [_long_list_of_kohana

How do I relate tables with different foreign key names in Kohana ORM?

◇◆丶佛笑我妖孽 提交于 2019-12-13 18:11:47
问题 I'm building a Kohaha application to manage sip lines in asterisk. I'm wanting to use ORM but I'm wondering how do relate certain tables that are already well established. e.g. the table sip_lines looks like this. +--------------------+------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+------------------+------+-----+-------------------+-----------------------------+ | id | int(10) unsigned |

Kohana 3.2: Calling model with underscore in name

安稳与你 提交于 2019-12-13 02:33:40
问题 I have the following model: class_user nammed after a table in my database clas_user. When I call this model with the following code: $class_user = new Model_Class_User(); It can't find my model. Within my model file, the class is named exactly the same way (Model_Class_User). Does Kohana not like model names with underscores? 回答1: Underscores directly reflect the file location in your app. Meaning your Class_User model file should be located in application/classes/model/class/user.php The

Kohana 3.2 - i want to get distinct dates

夙愿已清 提交于 2019-12-12 05:03:54
问题 so i have a table with the following: id transaction_timestamp (TIMESTAMP CURRENT_TIMESTAMP) i would like to get distinct dates from the transaction timestamp using Kohana ORM i have a Model named Model_Transactions if i do this Model_Transactions::factory('transactions')->find_all(); i get all data. how would i get only the distinct dates since i would use it as an archive. i dont want the user to click on an archive and returns a blank table. for example: user clicks "April 01, 2012" since

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

谁都会走 提交于 2019-12-06 05:38:17
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 * @return boolean */ public static function matches($array, $field, $match) { var_dump($array);exit;

Kohana v3.1.0 ORM _ignored_columns — now that it's gone, what should I do instead?

瘦欲@ 提交于 2019-12-05 15:52:23
It seems that in v3.1.0 of Kohana's ORM that the _ignored_columns property has been removed. What the is the recommended technique to dealing with fields that aren't in the databases? The case I have right now is password_confirm where password is a field, but we require the user to enter their password twice. You can pass an extra validation object to save, create and update. So your example would look like: /** * Password validation for plain passwords. * * @param array $values * @return Validation */ public static function get_password_validation($values) { return Validation::factory(

Is it possible to re-use a Kohana ORM query for the row count?

六眼飞鱼酱① 提交于 2019-12-05 00:32:03
问题 So I have my query as so... $records = ORM::factory('category'); Add a WHERE clause as so... $records = $records->where('categoryid', 'LIKE', 'aa'); Grab a count for pagination as so... $count = $records->count_all(); And my where clause gets cleared away as so... SELECT `categories`.* FROM `categories` LIMIT 20 OFFSET 0 With this line commented out //$count = $records->count_all(); My SQL looks just fine... SELECT `categories`.* FROM `categories` WHERE `categoryid` LIKE 'aa' LIMIT 20 OFFSET