IgnitedRecord 1.0 pre-release |
[eluser]Paul Apostol[/eluser]
Hi, I'm tying to figure how this library works. For the moment I have only one question: IR supports table and joining table prefixes? How? Thank you, Paul
[eluser]amrnt[/eluser]
hi guys... can any body help me ... the library works fine @ all ... but : the model Code: class Post extends IgnitedRecord { the controller Code: class Posts extends Controller { when i add a post ,it'll be added good... but the 'created_at' field has no changes ... why? is there something missed? please help me thanks in advance
[eluser]m4rw3r[/eluser]
@paul Apostol: The prefixing is done in IgnitedQuery, which is the query builder IR uses. IgnitedQuery is meant to be a replacement for AR, and thus it fetches the db prefix from the database configuration. (I haven't tested the prefixing enough, but the code seems to be good - tell me if you find any errors)
[eluser]Paul Apostol[/eluser]
Thanks m4rw3r, Do you know where I can find an "how to" for the way I can set the prefixes? I have to use the private methods? Can be set from the model? Thank you
[eluser]m4rw3r[/eluser]
The prefixes you talk about is a global prefix which is in the whole CI. So if you set the prefix to eg. "foo_" then the users table would be foo_users and the users_tags would become foo_users_tags. Also on setting it: Ci Database configuration (dbprefix) @amrtamimi: Waiting for flojon, because he wrote the timestamped behaviour (but I'll take a look too)
[eluser]Paul Apostol[/eluser]
OK, I understood. Really doesn't help me for my application/style of using tables. I want to have prefixes for sets of tables and not for whole application, depending on the area for which I'm using the tables. I'll try to see if I can make a little modification to the library.
[eluser]Paul Apostol[/eluser]
0. Anybody used an autoload for the IR models? 1. I get this error PHP Fatal error: Call to undefined method Loader::orm() 2. To have table prefixes independent from CI prefix I made some changes add in database config Code: $db['default']['irprefix'] = Array("app_"=>Array('levels')); - constructor change: $this->q_prefix = $CI->db->irprefix; function replace Code: function _prefix($str) - insert function replace: $sql = $CI->db->_insert($this->_protect_identifiers($this->q_prefix.$table), array_map(array(&$this, '_protect_identifiers'), $keys), $set); with $sql = $CI->db->_insert($this->_protect_identifiers($this->_add_prefix($table)), array_map(array(&$this, '_protect_identifiers'), $keys), $set); - update function replace $sql = $CI->db->_update($this->_protect_identifiers($this->q_prefix.$table), $set, array($this->_build_where($this->q_where)), $this->q_order_by, $this->q_limit); with $sql = $CI->db->_update($this->_protect_identifiers($this->_add_prefix($table)), $set, array($this->_build_where($this->q_where)), $this->q_order_by, $this->q_limit); Good Luck
[eluser]sofbas[/eluser]
@amrtamimi: How does you're data model look like? The behavior works fine for me, I did have an issue when the created_at column was a different name, but you can set that.
[eluser]m4rw3r[/eluser]
@paul Apostol: That shouldn't pose any problems, you just need to autoload the 'database' and 'ingitedrecord/ignitedrecord' libs too. This should work because the models are loaded after the libraries in CI's autoload. The error you have there is because your loader does not have an orm() method, have you copied this to the loader? or are you using PHP 4?
[eluser]Paul Apostol[/eluser]
Hello, I'm using php 5.2.6. The autoload contains database, session and ignitedrecord/ignitedrecord MY_Loader is in app/library folder. $this->load->model() works. As an extra I'm using HMVC 5.1. Could be the problem? EDIT: Autoloading done by ading the next code in IgnitedQuery class Code: static function autoload($class) and just before the class: Code: spl_autoload_register('IgnitedQuery::autoload'); Just be carefully to replace in autoload function in case you don't use HMVC the word 'modules' with 'models' |
Welcome Guest, Not a member yet? Register Sign In |