Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Work with database
  • Hello!

    I go deeper and deeper in FuelPHP. Thanks to you I go  faster :)

    Now I have a question about ORM using.

    I have a set of properties (fields) in one table, each property may be 1 or 0 (true or false, in MySQL - tinyint(1)). F.e.:

    property_1 - 1
    property_2 - 0
    property_3 - 0
    property_4 - 1

    There is a real name for each property, so for property_1 name "Property 1" and so on.

    And in the view I want to output real names only for those properties, which have 1 in corresponding field.

    Can you help me to find the best way for implementing this on FuelPHP?
  • I don't understand the question. Something like

    if ($model->property_1) echo "Property 1"; ?
  • I'll try to explain. Property can be (then 1 in table field in DB) or can not be (than 0 in table field in DB). How can I output names of only those properties where 1 in table field?
  • Isn't that what this does?

    if ($model->property_1) echo "Property 1"; ?
  • yes, it works :) I though that I should do it with cycle, but there is no problem to  write each property by hand :)
  • If it's not a relation, but individual columns, there's no other option then to do it by hand. There's nothing to loop over.

    If you have a lot of these properties, you might want to look at an EAV container, which is more flexible when it comes to recording different properties or attributes of an object.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion