Yii Framework Forum: need help for embedded document mongodb - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

need help for embedded document mongodb Rate Topic: -----

#1 User is offline   rajeshtomjoe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 07-March 11

Posted 11 March 2011 - 11:46 PM

i am working on mongodb using the extension yiimongodbsuite everything works fine with the extension but i am pretty much confused on how to store embedded documents to collection in mongodb database.
As following the documention of yiimongodbsuite i did the following(i used the examples)

1.generated crud for the model User with embeddedDocuments commented out
2.then uncommented the embeddedDocuments in user and added the model UserAddress
3.added a form fields for address fields in views _form file of user (like the one below)

<div class="row">
		<?php echo $form->labelEx($model->address,'city'); ?>
		<?php echo $form->textField($model->address,'city'); ?>
		<?php echo $form->error($model->address,'city'); ?>
	</div>

4.now i have a form field for city,house, apartment,zip code etc in the browser
5.the problem is that the values are not being added to collection in the database
i am getting the below collection to be stored in database

{
   "_id": ObjectId("4d7a32e86242e2b004000002"),
   "username": "cvcb",
   "email": "vbvc",
   "personal_number": "bvcbcx",
   "first_name": "bxcbxc",
   "last_name": "bbxcbvcbvcb",
   "client": "vbxvcbc",
   "company": "bcbvcbvc" 
}


rather than

{
   "_id": ObjectId("4d7a32e86242e2b004000002"),
   "username": "cvcb",
   "email": "vbvc",
   "personal_number": "bvcbcx",
   "first_name": "bxcbxc",
   "last_name": "bbxcbvcbvcb",
   "address":
   {
     "city":"chennai",
      ....
   }
   "client": "vbxvcbc",
   "company": "bcbvcbvc" 
}


can anyone help me out for this
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users