sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

The raw query interface #127

Open CriztianiX opened 8 years ago

CriztianiX commented 8 years ago

I'm a playing with sailor, and i see that Sailor does not provide a raw interface to execute queries.

So, i've added in resty_,mysql.lua something like this:

-- Gets instance for db
-- @return table_name
function db.get_instance()
    db.instantiate()
    db.connect()
    return db
end

And now i can do:

local db = require "sailor.db"
db.get_instance().query("SELECT * from articles") 

Why this feature is not available in the framework? Can be added with a PR? Thanks!

Etiene commented 8 years ago

Hello! PRs are always welcome! 👯

But which version of Sailor are you using? Isn't this method what you are looking for? https://github.com/sailorproject/sailor/blob/master/src/sailor/db/resty_mysql.lua#L55

CriztianiX commented 8 years ago

Hey, yes!, but can not call this method directly, because depends on instialisate, connect, etc. So, get_instance() give you a db's instance ready for work. Take a look my example.

Etiene commented 8 years ago

Oh yes, of course. Hmm... yea! maybe we need a refactor over there :D

CriztianiX commented 8 years ago

Yes, i think so, the db layer should be re-implemented. I can work in this, any idea? Desing? Architecture ?

Etiene commented 7 years ago

Which suggestions do you have in mind?

CriztianiX commented 7 years ago

https://github.com/CriztianiX/sailor/commit/944fba4c7e0dea08c5125cc50b5a95588d29bb3c

What do you think?

Etiene commented 7 years ago

Added a new comment over there! ^_^