Feature Request #3697
Late static binding on table dependent model settings
|Assignee:||Lorenzo Pisani||% Done:|
|Target version:||Kohana v3.x - Unscheduled|
There are many properties in the model which should be static, there is no need to have them in each object instance.
#4 Updated by David Farnan about 3 years ago
I would like to second this. I was actually looking for a way to create an inherited static "exists" function for my models which would use the primary key as input and return if the row exists for validation purposes. It seems looking at the code that this is a fairly simple change inside ORM since the model properties are already protected. I'm curious what the performance implications are.
#8 Updated by Kemal Delalic 11 months ago
Ok here is what I think about making static;
protected static $_column_cache = array(); protected static $_initialized = FALSE; protected static $_db = NULL; protected static $_db_group = NULL; protected static $_has_one = array(); protected static $_belongs_to = array(); protected static $_has_many = array(); protected static $_load_with = array(); protected static $_foreign_key_suffix = '_id'; protected static $_object_name; protected static $_object_plural; protected static $_table_name; protected static $_table_columns; protected static $_sorting; protected static $_updated_column = NULL; protected static $_created_column = NULL; protected static $_serialize_columns = array(); protected static $_primary_key = 'id'; protected static $_table_names_plural = TRUE; protected static $_reload_on_wakeup = TRUE; protected static $_errors_filename = NULL;
You'll notice that a few of these are already static. Do we need to enable 2 objects of the same class using different databases or something similar? All of these look quite straightforward otherwise
#9 Updated by Kemal Delalic 11 months ago
And this is what every instance of ORM would still contain;
protected $_validation = NULL; protected $_object = array(); protected $_changed = array(); protected $_original_values = array(); protected $_related = array(); protected $_valid = FALSE; protected $_loaded = FALSE; protected $_saved = FALSE; protected $_primary_key_value; protected $_db_applied = array(); protected $_db_pending = array(); protected $_db_reset = TRUE; protected $_db_builder; protected $_with_applied = array(); protected $_cast_data = array();
I have done the rewrite partially on localhost already and using it for a pet project, dumping ORM objects doesn't hurt your eyes nearly as much as it used to :)