0

i'm new to php and codeigniter but i have experience with pylons and sqlalchemy.

there you define model classes and then you use command something like "paster setup-app development.ini" and (paster?) creates tables for you and you dont have to write any sql code...

i was trying this with codeigniter and datamapper but so far i'm not sure if it is possible. so here i am asking you if it is possible?

i am very confused because in "models/" you can put your own classes (like in sqlalchemy). in these classes you define every attribute, relationship and other stuff. so why would you need to write the same thing 2 times? (1st in this class 2nd in sql script)

tereško
  • 58,060
  • 25
  • 98
  • 150
karantan
  • 885
  • 10
  • 18

1 Answers1

1

That is not possible, Datamapper implements the Active Record pattern which expects the tables to be there.

There is no need to define any attributes in a Datamapper model, it will be fetched from the associated table (and cached).

WanWizard
  • 2,574
  • 15
  • 13
  • http://datamapper.wanwizard.eu/pages/gettingstarted.html you must defined a model class. hmm pylons has this more elegant than CI... =/ – karantan Apr 07 '12 at 16:18
  • 1
    It all depends on that you call elegant. The Activerecord pattern has the data store as leading, where as in the Datamapper pattern, the definition is leading. Datamapper ORM expects you to do your database designwork first, then model your code. If you want to create tables from code, look at the Migrations library. – WanWizard May 07 '12 at 10:52