Questions tagged [fuelphp-orm]

FuelPHP's ORM is an Object Relational Mapper for the FuelPHP framework modeled after the Active Record Pattern.

FuelPHP's ORM (Object Relational Mapper) does 2 things: it maps your database table rows to objects and it allows you to establish relations between those objects.

It follows the Active Record Pattern closely, but was also influenced by other systems.

34 questions
2
votes
1 answer

Case insensitive `like` with FuelPHP's orm and mysql

I am using FuelPHP and MySQL, and would like to use the ORM to query with a case insensitive like query against a column with a case sensitive collation. For example, in my orm model, I'd like to do something like this: public static function…
johncorser
  • 9,262
  • 17
  • 57
  • 102
1
vote
1 answer

order by and group by in ORM (fuelphp)

I'm trying to order by and group by tag $result = Model_Tag::query()->select(\Fuel\Core\Db::expr('count(*)'),'count')->select('tag')->group_by('tag')->order_by('count','desc')->get(); $result = …
paullb
  • 4,293
  • 6
  • 37
  • 65
1
vote
1 answer

How to set dynamic condition for fuelphp ORM relation

I have a many-to-many relationship created using fuelphp's ORM. The pseudocode for the relation looks like this class MyModel extends Model { protected static $_many_many = [ 'relatedmodel' => [ 'conditions' => [ 'where' =>…
johncorser
  • 9,262
  • 17
  • 57
  • 102
1
vote
1 answer

How to add soft-delete to oil scaffold command?

I am running the command below on FuelPHP 1.7.3 in development mode: php oil g scaffold clients long_name:varchar[50] short_name:varchar[3] --updated-at=updated --created-at=created --deleted-at=deleted --soft-delete And it outputs the below as…
Dan Mason
  • 2,177
  • 1
  • 16
  • 38
1
vote
1 answer

Adding two of the same observer in Fuelphp (ORM)

Is there anyway to add two of the same type of observer to a Model in FuelPHP (ORM). (I'd actually be using a custom observer rather than the CreatedAt at shown below) protected static $_observers = array( 'Orm\\Observer_CreatedAt' => array( …
paullb
  • 4,293
  • 6
  • 37
  • 65
1
vote
1 answer

Fuel PHP - to_array() method and multiple belongs_to relationships and eager loading

I am attempting to migrate some legacy data models/schemas to a fuel API, and have run into an odd issue with the to_array() method on a model that has two $_belongs_to properties. When I load the model without the to_array() method, I properly…
jahsome
  • 881
  • 8
  • 18
1
vote
1 answer

FuelPHP - Many to Many and fields in relation table?

I think FuelPHP doesn't support this feature, but I would like to know the best way to do it.... I have 3 SQL tables: users, modules, modules_users. an user has many modules, and a module may have many users (who follow it). In modules_users,…
Allan Stepps
  • 1,047
  • 1
  • 10
  • 23
1
vote
2 answers

FuelPHP ORM one to one relation is not saving?

I'm trying to execute the following, the array contains some data that should be saved to the timeline table and the rest to the calendar table. However only the defaults or null data gets saved to the calendar while the timeline is updated…
CodeChap
  • 4,132
  • 6
  • 30
  • 40
1
vote
1 answer

FuelPHP Orm: set() for model with many_to_many relation and table_through

I have two models, Model_Post and Model_Category. I've managed to "find" all the related data (easy as $post->$categories), but now I need to create relationships (in the posts_categories table) between a post and multiple categories upon the post's…
Lowbie
  • 13
  • 3
1
vote
1 answer

FuelPHP - How do I access a custom sql statement using ORM?

Question Is it possible to create a custom SQL query and treat its results like you treat tables with FuelPHPs ORM? Example I have an SQL statement that pivots a table for me. The image below shows what the pivot SQL statement does. On the left we…
zechdc
  • 3,374
  • 9
  • 40
  • 52
1
vote
1 answer

FuelPHP ORM Primary Key on model cannot be changed

I've been banging my head with this ORM error: Fuel\Core\FuelException [ Error ]: Primary key on model Model_CustomValue cannot be changed. Here are relevant info from my models I'm having issues with:
bigdawggi
  • 76
  • 7
0
votes
3 answers

Use of models in FuelPHP?

I'm new to PHP frameworks and to start my venture I went to try FuelPHP. After a few days of testing around I understood how things work. Controllers control the actions, views control the $content and the template controls the layout. But what…
FBwall
  • 1,543
  • 3
  • 13
  • 15
0
votes
2 answers

Find a record where id is not the primary key in fuelphp

Is there any way to find a record using ORM in fuelphp if the primary key of the table is not id column? For example, listing_id is my primary key. And I couldn't get the desired result with: $listing_id = Input::get('listing_id'); $entry =…
Anoop S
  • 33
  • 2
  • 6
0
votes
3 answers

FuelPHP orm multiple AND,OR query

How can I execute this query using orm in fuelPHP? SELECT * FROM user when a=1 and b=2 and (c=1 or d=2 or e=3) I don't know how to implement this: and (c=1 or d=2 or e=3) I am stuck at: $where = array() $where[] = array('a'=>1,'b'=>2); …
Ryo
  • 995
  • 2
  • 25
  • 41
0
votes
2 answers

Fuelphp How to automatically populate a foreign key based on Primary key

Here's my user Controller public function action_create_student(){ $view = View::forge('admin/users/create_student'); if (Input::method() == 'POST') { $val = Model_User::validate('create'); if ($val->run()) { …
1
2 3