Hey guys,
I'm pretty new to FuelPHP.
My first question is what is the best place to put custom functions? Right now, I just made a new file, func.php, inside the app/classes folder and access it like $func = new Func. $func->function_name() - I don't think this is the best way to do it.
Secondly, for something I'm making, I'll be needing a lot of custom queries. Normally, I'd just use PDO's prepared statements and execute them, but I'm unsure how I'd go about sanitizing user input with DB::query(), without having to sanitize each individual variable.
Thanks!
i'm very new to fuel as well, but as far as i know "custom functions" (in codeigniter calles helpers ???) are not part of the fuels logic. you have to create new or extend existing class with static methods.
They are not because in Fuel everything is a class. We don't do "functions". The solution the TS came up with is indeed the way to go.
If you do need procedural functions, you can define them in your app bootstrap, or create a separate file for it and include it in your bootstrap, like the core bootstrap does with base.php.
Fuel's query builder doesn't do prepared statements, as it has to be generic and support different platforms. If you don't want to use the standard query building mechanism, you don't have the benefits from it either, so you'll have to do your own escaping.
2.0 is going to have a new query builder based on PDO, you could check with FrenkyNet if that supports prepared statements.