Lazy Loading does not works when using SQLite

im a newbie here just trying out Yii, by using it to a pet project,

actually its just a simple bookmarking website,

where any registered user can manage his/her own list of bookmarks.

so, just setting the context

  • i already created a sqlite3 database including the required tables/schemas.

    (including the proper primary keys and foreign keys and necessary pragma to enable fk).

  • properly setup Yii’s basic framework using yiic (im using wamp)

  • and used the Gii module for creating models and crud ops

here’s my sample database model

  • Category model (just a lookup, categoryID + category)

  • Bookmark model (contains a simple title+url and the category)

    so basically, if i want to know the category(text) of a bookmark,

    i just need to "$bookmark->category->Category",

    and the "lazy loading" approach of Yii will implicitly fetch the value from the database. right?

now, here’s my problem, the “lazy loading” part just wont’ work.

it just shows an error something in the line of "accessing property of a non object"

(btw, im in office that’s why i cant paste the exact text)

i thought, the "$bookmark->category" is returning a null reference,

so im stucked with it. i’ve searched the forum/wiki if there’s a thread related to this

but found none.

so there, please help me.

is it possible that i missed a configuration

or code that i need to implement for this to work?

any help will be appreciated,

thanks guys :)

btw, when i use MySql(using the latest version), it works perfectly.

just dont know why.

So far i know [font="Arial, sans-serif"][color="#222222"][size="4"]SQLite < 3.6.19 dose not support foreignkey constrains,but i suggest you that you should modify your sql schema for desired output.[/size][/color][/font]

im sure i took the latest SQLite library version

and im executing this pragma_foreign_keys to enforce foreign key constraints for every database call.

has anyone tried the lazy-loading of models using sqlite3.7+ as database?

or maybe there are some override in the model definition that i need to implement?

i tried to override the IsPrimaryKey() function in the model to explicitly specify the primary column name

and it worked. don’t know if it is in the documentation but i think it is the fix.