1.

How Can We Create A Model?

Answer»

We can create a model by using FOLLOWING CODE :

db.define_table('company', Field('NAME', notnull = True, unique = True), format = '%(name)s')

db.define_table(

'CONTACT',

Field('name', notnull = True),

Field('company', 'reference company'),

Field('picture', 'upload'),

Field('email', requires = IS_EMAIL()),

Field('phone_number', requires = IS_MATCH('[d-() ]+')),

Field('address'),

format = '%(name)s'

)

db.define_table(

'log',

Field('body', 'text', notnull = True),

Field('posted_on', 'datetime'),

Field('contact', 'reference contact')

We can create a model by using following code :

db.define_table('company', Field('name', notnull = True, unique = True), format = '%(name)s')

db.define_table(

'contact',

Field('name', notnull = True),

Field('company', 'reference company'),

Field('picture', 'upload'),

Field('email', requires = IS_EMAIL()),

Field('phone_number', requires = IS_MATCH('[d-() ]+')),

Field('address'),

format = '%(name)s'

)

db.define_table(

'log',

Field('body', 'text', notnull = True),

Field('posted_on', 'datetime'),

Field('contact', 'reference contact')



Discussion

No Comment Found