Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
WanWizard
a.k.a. WanWizard
Discussions
4
Comments
8242
Activity
model without id
Not required, the ORM requires a unique primary key. That does not have to be a number, and it does not have to be an auto_increment column. But if it isn't you have to assign the value yourself before you save the object.
Comment by
WanWizard
August 2015
permalink
oil
You can not generate a migration from a model at the moment. You can generate a migration from a table using the fromdb task. Not sure what you mean by module.
Comment by
WanWizard
August 2015
permalink
How to allow only routed url to be called with Rest controller?
Add a route for it and point it to a method that throws HttpNotFoundException or HttpNoAccessException (on the current Fuel version only). Route lookup are not recursive, once is route is found the lookup stops.
Comment by
WanWizard
August 2015
permalink
Environment Problems
Only use the config files in ./app/config for static configuration, config that is not dependent on the machine that application runs on, who runs it. etc. All other config, like database settings, logging, profiling, etc belongs in an environment…
Comment by
WanWizard
August 2015
permalink
Deleting model deletes relations
For next time, use http://bin.fuelphp.com for your code, and post the link instead. What happens is pretty obvious, you have configured cascade_delete on your belongs_to between group and users. Which basically means, that when you delete a agroup…
Comment by
WanWizard
August 2015
permalink
model without id
No, you should define the correct primary key in your model. Every ORM model needs a primary key, and if you don't define one, it defaults to 'id'. so add: protected static $_primary_key = array('otherfieldname');
Comment by
WanWizard
August 2015
permalink
Inserting json data into database as model
If you're doing bulk uploads, from a performance point of view it's better to use DB::Insert() instead of the ORM, it's much faster. If you have a json string, you can convert it to an assoc array using json_encode(). If the assoc ar…
Comment by
WanWizard
August 2015
permalink
E-mail is not unique?
No. email is used as a login name by Auth, so it must be unique.
Comment by
WanWizard
August 2015
permalink
How to render image when asset autorender is false?
Unless you're hardcoding your pages, normally you would always use a group. We use two for css ('header-first' and 'header-last') and four for js (header and footer, and for both first and last). And they are rendered in ou…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
Yes, and the complexity of making sure modules are loaded at the correct time. Your HMVC request should always be wrapped in a try/catch block to catch the possible HttpNotFoundException, so you can deal with missing dependencies gracefully. With s…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
Correct, the logic of how to build a page is entirely handled by the front controller. it uses a nestedset table to do a lookup of the requested URI, it will check which theme (and which page template of that theme) is needed for that page, it will…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
Not sure what you mean by "theme stuff in a module", and why it would be bad. A theme by definition is global for your app, you want a uniform look and feel for all pages. Which means that if your components/widgets that are being called …
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
That is poor design. How would the frontloader know what a valid page is and what not? The frontloader is in charge of creating your output, it should know! How would you deal with additional information on a page? Some could have a different men…
Comment by
WanWizard
August 2015
permalink
Undefined index when performing query
PHPErrorException's are standard PHP errors that are wrapped in an exception so they can be caught and handled. So this is a standard PHP notice. And it should tell you exactly where in the code it happens, in development mode exceptions are s…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
I'm still lost. If you have an application architecture that uses a frontcontroller to assemble the page, it should receive ALL requests (except for non-HTML reponses like API or downloads), there are no controllers that can be called directly…
Comment by
WanWizard
August 2015
permalink
file upload
There was a bug in the Upload package v2.0.3. Edit your composer.json file, change the version to 2.0.4, and run "composer update" to get the new version.
Comment by
WanWizard
August 2015
permalink
deleting relations
The opposite: // both main and related object already exist$user = Model_User::find(8);unset($user->posts[1]); $user->save(); Note that this removes the relation, it does not delete the post. If you want to delete the post, do // both main a…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
I don't have a clue what your on about. In the basics, every controller action is callable either by the browser or by an HMVC call. The only way to prevent a direct call is via routing (i.e. do not allow any routing to the method). Ideally, …
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
In MVC terms, the index.php is referred to as the front controller, so that is what confused me. That is what we use in our app framework, yes, and that is a regular controller. And that calls other controller actions via a secondary request, so ye…
Comment by
WanWizard
August 2015
permalink
Modules routing nightmare
Requests from the frontloader aren't HMVC calls, HMVC is a controller requesting a secondairy controller. So maybe you are talking about something else? Perhaps you should do one step back, and first explain what you want to do at the function…
Comment by
WanWizard
August 2015
permalink
How to define column as unique in a migration?
You can not define a column as unique. You can define a unique index for it. See http://fuelphp.com/docs/classes/database/dbutil.html#/method_create_index
Comment by
WanWizard
August 2015
permalink
How to render image when asset autorender is false?
Well, this is the downside of disabling auto-render. If you want auto rendering, don't disable it. For css and js you would always want to use a group, as they are usually rendered in one place (for css) or two places (for js).
Comment by
WanWizard
August 2015
permalink
E-mail is not unique?
That doesn't really make any difference, it will remain unique, even with a second index.
Comment by
WanWizard
August 2015
permalink
Must tables in ORM have an 'id' column?
You need to tell the where() which id column you mean: check_isgroupmember($group_id, $user_id) { $result = Model_Tmgroup::query() ->where('id', '=', $group_id) ->related('tmusers'…
Comment by
WanWizard
August 2015
permalink
Model query() function looks for column not defined in model
Correct. Depending on the operation performed, the ORM sometimes sets a column to NULL before deleting a record, which fails in a spectacular way if you have constraints. But you can leave them on, see if you run into this problem, and remove them…
Comment by
WanWizard
August 2015
permalink
More Comments
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
About
Username
WanWizard
Joined
January 2011
Visits
2,369
Last Active
4:15AM
Roles
Administrator