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
Restfull API, with Form
If you're in a namespaced class, you need to prefix classes from other namespaces. So you need to use \DB (Fuel's core classes live in the global namespace). Perhaps brush up on some basic PHP skills first?
Comment by
WanWizard
April 2015
permalink
Restfull API, with Form
If your table has an ORM model, you would use // assuming 0 is an invalid default value $movies = \Model_Movies::find_by_id_type( \Input::get('movies', 0)); If you don't use ORM: // you don't need as_object() if you want array…
Comment by
WanWizard
April 2015
permalink
Restfull API, with Form
That is what I wrote. If you want to use GET variables, you need to get them using Input::get(). Fuel is designed to use URI segments. And I have to warn you: writing queries like that is VERY insecure, your site will be open to SQL injection, and…
Comment by
WanWizard
April 2015
permalink
How can I return a calculated field in my model?
It's an observer you will have to write, as it is custom logic. It's only a few lines of code, and you can look at the pre-defined observers to see how they work and how you should create one. Observers are great for performing actions to…
Comment by
WanWizard
April 2015
permalink
How can I return a calculated field in my model?
pose_find event? If it is a custom field based on data in the original record, I would use an "after_load" observer that sets it.
Comment by
WanWizard
April 2015
permalink
Pagination and anchor hashtag
Yup. Or backport only the pagination class, I don't think it has dependencies. If you switch the core to 1.8/dev, you should also switch all fuel packages to 1.8/dev, to keep everything consistent.
Comment by
WanWizard
April 2015
permalink
Restfull API, with Form
I don't see the relation between GET variables and a DB query?
Comment by
WanWizard
April 2015
permalink
How can I return a calculated field in my model?
It doesn't work that way, ORM models don't use traditional class properties. You have to use assignment ($model->var = $value) or the set() method to set a custom property. This also means you can not pre-define them, unless you creat…
Comment by
WanWizard
April 2015
permalink
How can I return a calculated field in my model?
If you're talking about ORM, An ORM model object is an exact representation of a single record. You are not supposed to SELECT columns (although there is limited support), and there is therefore also limited support for using an alias in a se…
Comment by
WanWizard
April 2015
permalink
Does DBUtil play nice with transactions?
Thanks!
Comment by
WanWizard
April 2015
permalink
Restfull API, with Form
Sorry, my bad, wasn't paying enough attention to what you wrote. Fuel hasn't been designed to use GET variables, it uses URI segments. Additional segments are mapped to action method arguments. If you want to use GET variables, you have…
Comment by
WanWizard
April 2015
permalink
Pagination and anchor hashtag
I've seen a fix has already been comitted. ;-)
Comment by
WanWizard
April 2015
permalink
Does DBUtil play nice with transactions?
Could you raise a ticket for it at https://github.com/fuel/core/issues ?
Comment by
WanWizard
April 2015
permalink
Pagination and anchor hashtag
Could you document this issue, and report it at https://github.com/fuel/core/issues so it can be looked at?
Comment by
WanWizard
April 2015
permalink
Restfull API, with Form
Parameters are passed as method arguments, with a URL like http://localhost:8888/api/movies/?id=&type=adventure you define the method like so: public function get_movies($id, $type = null) { // your code } This makes the id required, and th…
Comment by
WanWizard
April 2015
permalink
Pagination and anchor hashtag
Have you tried just adding it to the pagination URL? You can add a dummy page number to it if needed, like "http://localhost/main/report/0#m", the Pagination class will replace the 0 in this example by the correct page number (if you set …
Comment by
WanWizard
April 2015
permalink
Does DBUtil play nice with transactions?
That is probably true, DBUtil methods generate their own custom SQL, then run a DB::query() to execute it. It's still mostly the old Kohana code, so I don't think transactions were even looked at. It would probably more logical to have th…
Comment by
WanWizard
April 2015
permalink
How to rename columns in DB::select_array
DB::select_array() uses the same syntax as the select() method: You pass an array of either strings (column names), or arrays (when you need an alias): ->select(array('id', array('name', 'alias')))-> ... will b…
Comment by
WanWizard
April 2015
permalink
How do I generate a model for existing tables?
There is a task called 'fromdb' which allows model generation from existing db tables. php oil g fromdb -h
Comment by
WanWizard
April 2015
permalink
Load current module config
You don't need to manually load the config file, packages are self-contained, if they need config, they will load it. Auth does need to be in the "always_load" packages section though. If not, the package isn't known to the auto…
Comment by
WanWizard
April 2015
permalink
May I include fake property for validation purposes?
You can not add fake properties to an ORM model, it will confuse the ORM. But you can add additional fields to the validation instance without problems. When the fieldset for the ORM model is created, it calls the method "set_form_fields"…
Comment by
WanWizard
April 2015
permalink
How to localize Orm\\Observer_Validation messages?
There is a validation language file that is used by the Validation class. The enlish version is in ./fuel/core/lang/en. You can add translations like normal. And calling validation manually like this is absolutely fine.
Comment by
WanWizard
April 2015
permalink
Pass two variable with router
:segment matches only a single segment, :any matches zero or more segments. So If you have a URL like this: "/blog/post/12/comments/10" and you have a route like this: "blog/post(:any)" => "load/$1", the route wil…
Comment by
WanWizard
April 2015
permalink
Pass two variable with router
You don't need to write your own regex, you can also use 'blog/(:segment)' => 'post/list/$1', 'blog/(:segment)/(:segment)' => 'post/view/$1/$2',or even 'blog/(:any)' => 'post/list/…
Comment by
WanWizard
April 2015
permalink
Pass two variable with router
With your routing config you do "hide" it from the outside world, but not from the framework itself. The framework (the Request class) just sees the final route, which will be either "post/list" or "post/view", so crea…
Comment by
WanWizard
April 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,368
Last Active
5:08PM
Roles
Administrator