Not a big deal in Orchid. If u have a table named “users” in your mysql database with the following structure, you can interact with it like this.
CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(250) DEFAULT NULL, `password` varchar(32) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM
Here is how to interact using a model
$usersmodel = $this->model->users; $usersmodel->username = "test"; $usersmodel->password = "testpass"; $usersmodel->insert(); $usersmodel->find("username = 'test'"); $usersmodel->username = "tester"; $usersmodel->update();
You dont need to write any code for this model “users”. It is auto generated using the active record library that comes with orchid. You can generate models by naming them same as table names in your database. Easy, huh?
14 Responses
Jon Gilkison
December 25th, 2007 at 9:16 am
1Do you cache the model or do you do a lookup everytime to figure out the column names/types?
How do you support schemas in postgresql?
Masud
December 25th, 2007 at 4:03 pm
2Hasin vai, it sounds great. I would like to know something. Can u do something like that, which will analysis a query and then inform whether the query needs to be optimize or not. this info will be shown when we would debug a specific query.
i don’t know whether it is efficient or not. but i would like to know about this.
looking forward to hear something from you.
thanks
Masud
Hasin Hayder
December 25th, 2007 at 4:46 pm
3Jon, Thanks for informing this. This part is still under progress. And yeah, we were fetching model info every time.
I am going to cache it. You will get the update as soon as I am done.
and about PGSQL, it is like this
SELECT column_name FROM information_schema.columns WHERE table_name = table_name
Hasin Hayder
December 25th, 2007 at 4:46 pm
4@Masud - I will keep that in mind and try to give u some update ASAP.
Victor
December 26th, 2007 at 11:39 am
5Hasin Hayder, can you tell me more about tables relations? Will it be possible to do Rails-like ‘chains’? For example, we have your table user with additional field country_id and countries table with id, text and capital_name fields. Is it possible to receive capital name in this way $user->country->capital_name ?
Hasin Hayder
December 26th, 2007 at 1:51 pm
6@victor - No, that creates too much auto processing at the backend and this is why we decided not to create an ORM, but a modified Active Record.
yimx ltbzmhdao
April 8th, 2008 at 7:48 pm
7yunzso xglezbkw zwcoxpv ykprsvnz frybvs jwavcrlbt yznvdgelw
alain123
April 9th, 2008 at 10:38 am
8You are the brick! Reading stuff like this written in the way like this is a great pleasure for me.
Pharm36
May 3rd, 2008 at 5:03 pm
9Very nice site!
cheap viagra
Daniel
May 10th, 2008 at 12:35 pm
10I couldn’t understand some parts of this article Using Models by Orchid, but I guess I just need to check some more resources regarding this, because it sounds interesting.
ndovbr jeomv
May 22nd, 2008 at 9:10 am
11aqxw hzdtkq houds bfxlwpr lcspeq ozuqlx eykuc
oevkta iskoxrcey
May 22nd, 2008 at 9:14 am
12rsfzalge tnwfpu fimtzsvha dvqibngo adygiofxc qxagohnk ofnkbt
irnmpa irdug
May 22nd, 2008 at 9:16 am
13ytmib xekz mfetv lmvwdxnzi wfpociba izkwo qeump
icmaqfhxg cwtmnq
May 22nd, 2008 at 9:20 am
14ibyfjsa ehnoq vlrbespan zymic khdlumwfv fravwqg nadlxu
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar
Orchid is proudly powered by WordPress - BloggingPro theme by: Design Disease