Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorupupnaway
     
    I'm trying to translate a RoR tutorial to Akelos, but am having a hard time with PHP's implementation of class methods. In ruby, you simply use the "self." before the method name. How would the code below translate to Akelos and PHP5?

    ruby code:

    (in controller)

    class StoreController < ApplicationController

    def index
    @products = Product.find_products_for_sale
    end

    end


    this calls a method in the Product model--find_products_for_sale.

    (in model)

    class Product < ActiveRecord::Base

    def self.find_products_for_sale
    find(:all, :order => "title")
    end

    end


    The method is defined as a class method. But in PHP I need to use "static" keyword?
    Any help would be appreciated. Thanks
    • CommentAuthorKaste
     

    There is a huge difference between class-methods in ruby and static-methods in PHP I dont wanna discuss here.

    Anyway your example is very easy:

    function index()
    {
        $this->products =& $this->Product->findProductsForSale();
    }
    
    function findProductsForSale()
    {
        return $this->find([...]);
    }