Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created June 12, 2011 15:18
Show Gist options
  • Save francescoagati/1021664 to your computer and use it in GitHub Desktop.
Save francescoagati/1021664 to your computer and use it in GitHub Desktop.
phare with idiorm -> sql and lisp and php
(:: ORM (configure "mysql:host=localhost;dbname=my_database"))
(:: ORM (configure #username #database_user))
(:: ORM (configure #password #top_secret ))
(def people
(-> (:: ORM (for_table #person))
(where #name "Fred")
(where_raw "(`age` = ? OR `age` = ?)" [20,25])
(order_by_asc #name)
(find_many)
))
(def user (-> (:: ORM (for_table #users)) (find_one 5)))
(= (-> user age) 20)
(-> user (save))
<?php
require_once('/Users/Francesco/Downloads/Scriptor-pharen-aea8dc4/lang.php');
Lexical::$scopes['bindings'] = array();
$__scope_id = Lexical::init_closure("bindings", 55);
ORM::configure("mysql:host=localhost;dbname=my_database");
ORM::configure("username", "database_user");
ORM::configure("password", "top_secret");
$people = ORM::for_table("person")->where("name", "Fred")->where_raw("(`age` = ? OR `age` = ?)", array(20, 25))->order_by_asc("name")->find_many();
Lexical::bind_lexing("bindings", 55, '$people', $people);
$user = ORM::for_table("users")->find_one(5);
Lexical::bind_lexing("bindings", 55, '$user', $user);
$user->age = 20;
$user->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment