We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

[Help] Custom routing from DB and Custom my DB function

Hi ! I want config my project set router from database (parse web address) and i want buid custom DB function used for other model files. Plz help me. Thank all !



43.9k

Hi,

I want config my project set router from database

Can you explain what you exactly want to achieve ? Give us an example

i want buid custom DB function used for other model files

Create a BaseModel class, where you will put all your custom methods. Extend all your models from that BaseModel class

edited May '17

Thank for help me !

(1) I want rewrite url mysite.com/product/10 to mysite.com/product-url url product stored in slug table [request_url - product_id - controller] Eg: mysite.com/product-url -> this called module frontend , controller product, action index & param product_id = 10 mysite.com/admin/product-manager/edit/10 -> this called module backend , controller product, action edit & param product_id = 10

(2) This is content of Db model extends Phalcon Model

-

and this is content of Slug Model extends Db model

I call getSlug in Slug model then return error "Unknown method fetchOne on line 29 in Db model"

But i call function fetchOne from Db model ( (new Db)->fetchOne($sql) ) -> return true

Why ???

Hi,

I want config my project set router from database

Can you explain what you exactly want to achieve ? Give us an example

i want buid custom DB function used for other model files

Create a BaseModel class, where you will put all your custom methods. Extend all your models from that BaseModel class