Need Help w/ ORM Library |
[eluser]Michael Wales[/eluser]
I'm working on my own ORM Library and I can't seem to figure this part out. First off, here's the library (obviously, not complete): Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed.'); The issue I am having is within the get_related() method, particularly this line: Code: $var = $this->has_many Let's take a look at my model - to see exactly what we're trying to accomplish here: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed.'); So, Accounts has_many Users - and the get_related method, should equates to the following (in theory): Code: // All in all: $this->db->get_where('users', array('account_id'=>1)); If I hardcode the $this->$var portion to $this->users, it works perfectly fine. Obviously, this is not the best solution because it won't work for every possible scenario. Here's the Controller so you can see the "end developer" code and how I would like this to function. Code: function index() { Any ideas? The error I get is: Quote:Parse error: syntax error, unexpected T_VARIABLE in E:\xampplite\htdocs\tiara\libraries\MY_Model.php on line 43
[eluser]Michael Wales[/eluser]
Holy smokes... I'm retarded. This one piece of code has been giving me such a hard time - I've been trying everything. This line was a last minute "attempt": Code: $var = $this->has_many In my frustration, I failed to notice the missing semicolon on the first line. Add that in - and everything works as expected. Leaving this post up so everyone can look at the new hotness I'll be posting on my blog when it's completed.
[eluser]Rick Jolly[/eluser]
Michael, that might just justify an editor upgrade.
[eluser]Daniel Moore[/eluser]
Every time I get that error (not as much as I used to) the missing semicolon is the first thing I always look for. Anytime there's an unexpected T_anything, in most cases it's because of a missing semicolon, parenthesis, bracket or brace. Looking forward to seeing the complete stuff on the blog. |
Welcome Guest, Not a member yet? Register Sign In |