using idiorm in lisp with pharen
macros
(defmacro orm-config (type host db username password)
'(do
(:: ORM (configure (. ~type ":host=" ~host ";dbname=" ~db )))
(:: ORM (configure "username" ~username))
(:: ORM (configure "password" ~password))
)
)
(micro table-for (tbl) (:: ORM (for_table ~tbl)))
(defmacro orm-select (tbl fields where order)
'(-> (table-for ~tbl) (select ~fields) (where ~where) (order ~order) (find-many)))
example
(orm-config #mysql #127.0.0.1 #db_my #root #root)
(-> (table-for #users)
(where #id 5)
(find_one)
)
(orm-select #users "name,surname" (. "id=" 2) "id desc")
Written by francesco agati
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#