Relationship Activerecord PHP

Asked

Viewed 144 times

1

I have two tables, requests and half-payment on the table pedidos have the Foreign key meio_pagamento_id, how I define their relationship through activerecord php?

I tried to:

Class Meiopagamento

class MeioPagamento extends ActiveRecord\Model{
    static $table_name = 'meio_pagamento';
    static $has_many = array(
        array('pedido', 'class_name' => 'Pedido', 'foreign_key' => 'meio_pagamento_id')        
    );
}

Request Class

class Pedido extends ActiveRecord\Model{
    static $belongs_to = array(
        array('pagamento'),
        array('empresa'),
        array('meio_pagamento', 'class_name' => 'MeioPagamento', 'foreign_key' => 'meio_pagamento_id')
    );

    static $has_many = array(
        array(
            'itens', 
            'class_name' => 'Item', 
            'foreign_key' => 'pedido_id', 
            'primary_key' => 'id'
        )
    );
}
  • This Activerecord is from some framework:?

  • It is Activerecord PHP. I forgot to inform.

  • http://www.phpactiverecord.org/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.