Giter Site home page Giter Site logo

yiimongodbsuite's People

Contributors

canni avatar josemartinez avatar mrbig avatar pgaultier avatar tyohan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yiimongodbsuite's Issues

GeoSpatial Support

Hi Guys,

I'm trying to see if I can use some of the geospatial features of mongodb through this suite. I've everything installed and working, just trying to do some of the less used mongodb calls like

db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20)

Where 50,50 would be a longitude and latitude. Got any ideas how I could port this into your yii suite?

Thanks!
-tim

http://www.mongodb.org/display/DOCS/Geospatial+Indexing

EMongoEmbeddedDocument.php aftervalidate errors

hi, i dont know this is a bug or feature, but...
i have an EMongoDocument with name attribute
and it has a location embedded document
the location has name attribute too
like this:
{
name: '',
location: {
name: ''
}
}

i created a form from this
if name and location.name is required too
and location.name is empty but name has value
in error list i see the name is empty too

i think this function adds extra error message to name attribute:

    /**
     * @since v1.0.8
     */
    public function afterValidate()
    {
        if($this->hasEmbeddedDocuments())
            foreach($this->_embedded as $doc)
            {
                if(!$doc->validate())
                {
                    $this->addErrors($doc->getErrors());
                }
            }
    }

sorry if it is not a real bug, im new yii/mongo user and im new on github

Strange error

I use Gii MongoCURD to gen codes

when access admin page get below error:

PHP Error
Description
Undefined index: Feed
Source File
D:\www\feed\feed.cdeledu.com\protected\extensions\YiiMongoDbSuite\EMongoDocument.php(331)
00319: * Get value of use cursor flag
00320: *
00321: * It will return the nearest not null value in order:
00322: * - Object level
00323: * - Model level
00324: * - Glopal level (always set)
00325: * @return boolean
00326: */
00327: public function getUseCursor()
00328: {
00329: if($this->useCursor !== null)
00330: return $this->useCursor; // We have flag set, return it

00320: *
00321: * It will return the nearest not null value in order:
00322: * - Object level
00323: * - Model level
00324: * - Glopal level (always set)
00325: * @return boolean
00326: */
00327: public function getUseCursor()
00328: {
00329: if($this->useCursor !== null)
00330: return $this->useCursor; // We have flag set, return it

00320: *
ot null value in order:
00322: * - Object level
00323: * - Model level
00324: * - Glopal level (always set)
00325: *

why $_models is empty?

Getting MongoException when calling save method

Hi.

I faced a problem when I called save method to save new object.

I used it in model to extend EMongoDocument.
When I called method save in Controller I got MongoException with empty message.
The problem is that before it was working fine, after some changes, this exception started to be thrown every time. I didn't investigate the reason yet.

Before that, I was facing this problem, but it was solved. The reason of appearing was as unknown as it's disappearing.

That's how it looks.
http://awesomescreenshot.com/0ach5tm09

Mongo Version

$ mongod --version
db version v2.0.4, pdfile version 4.5
Tue Sep 25 20:11:54 git version: nogitversion

PHP version

$ php --version
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli) (built: Sep 12 2012 18:59:41)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH

Add support for default Mongo operators in EMongoCriteria ('$gt')

If you pass in a configuration array of 'conditions' into the EMongoCriteria, it will error if you use a default operator like '$gt'. It is happy to translate the '>' operator to the Mongo one using the $operators array in EMongoCriteria, but it does not allow using the actual '$gt' operator. Should be an easy fix and allow folks already familiar with Mongo queries to more easily use this (great!) extension, without learning the operator alias ('greater' and '>').

Thanks

Can not use fixture in test case.

Everything is ok in using YiiMongoDbSuite, but when use fixture in the test, it show an error:

CDbConnection.connectionString cannot be empty.

Bug with MultiModel code

On this page: http://canni.github.com/YiiMongoDbSuite/xhtml/special.multimodel.html

Code:

       $model = new NormalClient(null); // We have to set scenario to null, it will be set, by populateRecord, later
        else if($attributes['type'] == self::BUSINESS_CLIENT)
            $model = new BusinessClient(null);

should be:

Code:

       $model = new NormalClient(null); // We have to set scenario to null, it will be set, by populateRecord, later
        else if($attributes['type'] === self::BUSINESS_CLIENT) <-- changed
            $model = new BusinessClient(null);
        else <-- added
            $model = new Client(null); <-- added

It's needed so that if we're calling delete on a model (using it's Pk), it doesn't try to add in a type value as well. The == was assuming that type = 0 where it was really being sent a blank line.

Connect to 2 different Mongodb Servers

What if i want to connect to 2 different mongodb servers? For example, i need to connect to mongodb server that stores user identity, and connect to other mongodb server that stores something else...

types

As you can specify the types of fields. example I want to чотб user_id was always an integer and I don't want to override the beforeValidation

Fixed $OR operator in EMongoCriteria.php

Hi,

EMongoCriteria works better (for me) if you replace code in function addCond to

if($op == self::$operators['or'])
                {
                        if(!isset($this->_conditions[$op]))
                        {
                                $this->_conditions[$op] = array();
                        }
                        // disabled
                        // $this->_conditions[$op][] = array($fieldName=>$value);

                        // added

                        if (!is_array($value))
                                $this->_conditions[$op][] = array($fieldName=>$value);
                        else
                                foreach($value as $row)
                                {
                                        $this->_conditions[$op][] = array($fieldName=>$row);
                                }
                    
                }

search method implement of EMongoDocument seems to not work

hi canni :
i use the gii generate the views , but in admin view , there come out some exception :

Fatal error: Call to a member function getDbCriteria() on a non-object in C:\xampp\htdocs\my\livmx\protected\extensions\YiiMongoDbSuite\EMongoDocumentDataProvider.php on line 73

you can check the EMongoDocument and admin view , i don't know the reason but this two place seems to be mess:
/**
* Magic search method, provides basic search functionality.
*
* Returns EMongoDocument object ($this) with criteria set to
* rexexp: /$attributeValue/i
* used for Data provider search functionality
* @param boolean $caseSensitive whathever do a case-sensitive search, default to false
* @return EMongoDocument
* @SInCE v1.2.2
*/
public function search($caseSensitive = false)
{
$criteria = $this->getDbCriteria();

    foreach($this->getSafeAttributeNames() as $attribute)
    {
        if($this->$attribute !== null && $this->$attribute !== '')
        {
            if(is_array($this->$attribute) || is_object($this->$attribute))
                $criteria->$attribute = $this->$attribute;
            else if(preg_match('/^(?:\s*(<>|<=|>=|<|>|=|!=|==))?(.*)$/',$this->$attribute,$matches))
            {
                $op = $matches[1];
                $value = $matches[2];

                if($op === '=') $op = '==';

                if($op !== '')
                    call_user_func(array($criteria, $attribute), $op, is_numeric($value) ? floatval($value) : $value);
                else
                    $criteria->$attribute = new MongoRegex($caseSensitive ? '/'.$this->$attribute.'/' : '/'.$this->$attribute.'/i');
            }
        }
    }

    $this->setDbCriteria($criteria);

    return new EMongoDocumentDataProvider($this);
}

you comment : Returns EMongoDocument object ($this) with criteria set to
but the end of the method witch return an instance of EMongoDocmentDataProvider;

in the admin view :

widget('zii.widgets.grid.CGridView', array( 'id'=>'product-type-attr-grid', 'dataProvider'=>new EMongoDocumentDataProvider($model->search(), array( 'sort'=>array( 'attributes'=>array( 'productTypeName', 'inputType', 'dataType', 'modelAttribute', 'label', 'value', /* 'items', 'htmlOptions', '_id', */ ), ), )), so you see :)

EEmbeddedArraysBehavior

Been trying to get this to work for validation.
Since you cannot add entries in "embeddedDocuments()" for the arrays you define they have no "_embeddedConfig" entry. So the validation will never be called. It's not a complete disaster and I wrote a workaround for it, but I just wanted to let you know :)

Also in the EEmbeddedArraysBehavior::attach() you refer to "$testObj" in the errormessage, which does not exists.

Awesome work on the extension btw!

Embedded doc containing embedded array of docs

With the following configuration:

class Test extends EMongoDocument {
    public function embeddedDocuments() {
        return array('test1' => 'Test1'),
    }
}

class Test1 extends EMongoEmbeddedDocument {
    public $test2;

    public function behaviors() {
        return array(
            'test2Behavior => array(
                'class'=>'ext.mongodb.extra.EEmbeddedArraysBehavior',
                'arrayPropertyName'=>'test2',       // name of property, that will be used as an array
                'arrayDocClassName'=>'Test2'    // class name of embedded documents in array
            ),
        ),
    }
}

class Test2 extends EMongoEmbeddedDocument {
    public $property1;
}

I cannot access:

$test = Test::model()->findByPk($id);
$val = $test->test1->test2[0]->property1;

actually I can do the following:

$val = $test->test1->test2[0]['property1'];

i.e. arrays are not being converted to objects.

Undefined index on EMongoModifier

Hi canni,

I found a bug on EMongoModifier.php file in line 98

we can get an Exception "Undefined index" on the following line

is_array($modifier[$operator])

Of course, you will only get this error if your server is configured to report notices.

You can fix it changing the line by the following:

if(isset($modifier[$operator]) && is_array($modifier[$operator])) // we check before if index is set

Best regards

EMongoUniqueValidator and ClassName doesn't work

Hello, congrats and thank you for EMongoUniqueValidator script!, I am Andrés from Chile, I have implemented YiiMongoDbSuite in a proyect for study and learn to MongoDB, but I have a little problem, I need validate field "Email" of my document but doesn't work, My form "RegistroForm" extends from CFormModel and my rule is:
array('email', 'ext.YiiMongoDbSuite.extra.EMongoUniqueValidator', 'className' => 'Usuario'),

But in the webpage appears this error: The property "EMongoUniqueValidator"."className" has not defined.

Because the form "RegistroForm" is not a Model (EMongoDocument), the Model is "Usuario". how can I resolve this?, can any one help me?

broken yiii shell

Hello,

When I try the yiic shell on a normal project (mysql) it works. But on a projecy using YiiMongoDbSuite it outputs the html generated for an error page as follows:

PHP Error

include(Mongo.php): failed to open stream: No such file or directory

/home/lpanebr/Libraries/webdev/yii-1.1.6.r2877/framework/YiiBase.php(395)

383      * @return boolean whether the class has been loaded successfully
384      */
385     public static function autoload($className)
386     {
387         // use include so that the error PHP file may appear
388         if(isset(self::$_coreClasses[$className]))
389             include(YII_PATH.self::$_coreClasses[$className]);
390         else if(isset(self::$classMap[$className]))
391             include(self::$classMap[$className]);
392         else
393         {
394             if(strpos($className,'\\')===false)
395                 include($className.'.php');
396             else  // class name with namespace in PHP 5.3
397             {
398                 $namespace=str_replace('\\','.',ltrim($className,'\\'));
399                 if(($path=self::getPathOfAlias($namespace))!==false)
400                     include($path.'.php');
401                 else
402                     return false;
403             }
404             return class_exists($className,false) || interface_exists($className,false);
405         }
406         return true;
407     }
<div class="traces">
    <h2>Stack Trace</h2>

Any ideas as how do I get Yii shell running with yiimongodbsuite?

Thanks for this awesome job!!

f/sessionHandler destroy

Hi Canni,
I have tested your new feature sessionHandler in my application and i'm having a trouble with it. I dont know if its a bug on the code or not.

Step1
I connect to the login page of my application
A record is created on database with an Id, expire and empty data

Step2
I login on the application
Record is updated on database with some data='xxxxx'

Step3
I logout using Yii::app()->user->logout(); (i didnt extend user, so im using CWebUser)
Logout seems to be successful, but i still have data='xxxx', so application doesnt knows that user logged out.

After some debug i noticed that we call once to EMongoHttpSession->destroySession and i see that we remove correctly the record with the id, but later it seems that 'data' field is restored from .... maybe SESSION? (asynchronous treatement between database and session, i dont know..)

I wanted to know if you noticed this behavior or i just have something wrong in my application.

Thank you very much

Best regards

Call to a member function getConditions() on a non-object

I'm wondering if its a bug or not, because you dont find without criteria but...

On EMongoDocument.php file line 670 you have

"public function find($criteria=null)"

then you do:

"$criteria->getConditions()"

if criteria is null you get an error. Maybe check if its null before getConditions?

findAll seems not work

Hi,
I don't know if it's a problem, but the findAll method return alwas an empty object.
Instead, find method return one result.

Issue with beforeDelete event

If you try to put smth in beforeDelete this will get called twice when executing $model->delete() because of the "$this->beforeDelete()" from deleteByPk. In the initial CActiveRecord class, in delete method, they don`t do a beforeDelete, just delete the record.

test case fixtures error

When use phpunit to test and using fixtures, get an error:

  1. FeedTest::testAddFeed
    CException: EMongoDB does not have a method named "getSchema".

D:\www\yii-1.1.5.r2654\framework\base\CComponent.php:266
D:\www\yii-1.1.5.r2654\framework\test\CDbFixtureManager.php:231
D:\www\yii-1.1.5.r2654\framework\test\CDbFixtureManager.php:113
D:\www\yii-1.1.5.r2654\framework\test\CDbFixtureManager.php:85
D:\www\yii-1.1.5.r2654\framework\base\CModule.php:372
D:\www\yii-1.1.5.r2654\framework\test\CWebTestCase.php:69
D:\www\yii-1.1.5.r2654\framework\test\CWebTestCase.php:101
D:\www\feed\feed.cdeledu.com\protected\tests\WebTestCase.php:22

EMongoDocument::init Indexed Key Unique Bug

Int EMongoDocument::init, the logic grabs all the indices for that mongo collection. The code also assumes that all indices are unique. The code:
$indexes[$index['name']] = array(
'key'=>$index['key'],
'unique'=>$index['unique'],
);

Breaks if the index is NOT unique. Need to add logic there to check if the key is unique or not before indexing 'unique'.

Can not use fixture in test case.

Everything is ok in using YiiMongoDbSuite, but when use fixture in the test, it show an error:

CDbConnection.connectionString cannot be empty.

weird error with Undefined Index...

Hello again. Perhaps you can shred some light with this. I have two desktop computers where I code. The only diference is one is 64bit ubuntu and the other 32bit ubuntu both 10.04.

On the 32bit I get the following when I access admin views for exemple: http://cmsa/index.php?r=news/admin

<h1>PHP Error</h1> 

<p class="message"> 
    Undefined index: News   </p> 

<div class="source"> 
    <p class="file">/home/lpanebr/mysites/cmsa/protected/extensions/YiiMongoDbSuite/EMongoDocument.php(331)</p> 
    <div class="code"><pre><span class="ln">319</span>      * Get value of use cursor flag

320 *
321 * It will return the nearest not null value in order:
322 * - Object level
323 * - Model level
324 * - Glopal level (always set)
325 * @return boolean
326 _/
327 public function getUseCursor()
328 {
329 if($this->useCursor !== null)
330 return $this->useCursor; // We have flag set, return it
331 if(self::$_models[get_class($this)]->useCursor !== null)
332 return self::$models[get_class($this)]->useCursor; // Model have flag set, return it
333 return $this->getMongoDBComponent()->useCursor;
334 }
335
336 /
*
337 * Set object level value of use cursor flag
338 * @param boolean $useCursor true|false value for use cursor flag
339 */
340 public function setUseCursor($useCursor)
341 {
342 $this->useCursor = ($useCursor == true);
343 }

Bug in code in documentation for MultiModel

Just copied/pasted your code in to get started from this page:

http://canni.github.com/YiiMongoDbSuite/xhtml/special.multimodel.html

In the code example for NormalClient/BusinessClient, the beforeSave function needs a semi-colon at the end:

public function beforeSave()
{
if(parent::beforeSave())
{
$this->type = self::NORMAL_CLIENT;
return true;
}
else return false
}

needs to be:
public function beforeSave()
{
if(parent::beforeSave())
{
$this->type = self::NORMAL_CLIENT;
return true;
}
else return false; // <-- change made here
}

Thanks for all your work on this!

EMongoDocument's EMongoCriteria change when assigning consecutive criteria

I was assigning 2 slightly different criteria to 2 EMongoDocumentDataProviders but for some reason, the criteria of the second overwrote the criteria of the first. Because the getData of the DataProvider is run in the view (in a list widget). the results of the second criteria were shown instead of the first. This does not happen if the data is cached via getData before the second criteria is assigned to a dataprovider's constructor.

In the constructor of EMongoDocumentDataProvider:
$this->_criteria = $this->model->getDbCriteria();

If I change this to
$this->_criteria = new EMongoCriteria();

it works as it should.

How to replicate (change the conditions to fit your own model):
$a = new EMongoCriteria('conditions' => array('category' => 1);
$aProvider = new EMongoDocumentDataProvider('MyModel', array('criteria' => $a));
var_dump($aProvider->getCriteria());

$b = new EMongoCriteria('conditions' => array('category' => 2);
$bProvider = new EMongoDocumentDataProvider('MyModel', array('criteria' => $b));
var_dump($aProvider->getCriteria());

First var_dump shows $a criteria, second shows $b criteria, while it should show $a criteria.

config/main.php suggestions for setup page

I just ran into some glitches with urlManager rules combined with MongoDb Ids (which are strings instead of ints). Here's what I came up with in case you want to update the setup page in the manual (http://canni.github.com/YiiMongoDbSuite/xhtml/setup.html):

'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
// 'controller:w+/id:d+'=>'/view',
// 'controller:w+/action:w+/id:d+'=>'/',
'controller:w+/action:w+'=>'/',
'controller:w+/action:w+/id:w+'=>'/',
'controller:w+/id:w+'=>'/view',
),
),

Thanks, this is turning out really nicely!

embedded documents loads only safe attributes

Attributes not marked safe in embedded document are not loaded by the find() methods.

This is caused by the default setAttribute method of CModel, that does not pass on the safeOnly parameter. To correct this I've overridden the setAttribute method in EMongoEmbeddedDocument.

Please check the commit at:
mrbig@0578e5d

actionAdmin() in controller throws an php error after generating it with gii mongocrud

Have problem when trying to access admin action it throws php error: full error output is below:
PHP Error
Description

Undefined index: Country
Source File

C:\web\ski\protected\extensions\YiiMongoDbSuite\EMongoDocument.php(331)

00319: * Get value of use cursor flag
00320: *
00321: * It will return the nearest not null value in order:
00322: * - Object level
00323: * - Model level
00324: * - Glopal level (always set)
00325: * @return boolean
00326: _/
00327: public function getUseCursor()
00328: {
00329: if($this->useCursor !== null)
00330: return $this->useCursor; // We have flag set, return it
00331: if(self::$_models[get_class($this)]->useCursor !== null)
00332: return self::$models[get_class($this)]->useCursor; // Model have flag set, return it
00333: return $this->getMongoDBComponent()->useCursor;
00334: }
00335:
00336: /
*
00337: * Set object level value of use cursor flag
00338: * @param boolean $useCursor true|false value for use cursor flag
00339: */
00340: public function setUseCursor($useCursor)
00341: {
00342: $this->useCursor = ($useCursor == true);
00343: }

Stack Trace
#0 C:\web\ski\protected\extensions\YiiMongoDbSuite\EMongoDocument.php(826): Country->getUseCursor()
#1 C:\web\ski\protected\extensions\YiiMongoDbSuite\EMongoDocumentDataProvider.php(141): Country->findAll()
#2 C:\yii\framework\web\CDataProvider.php(128): EMongoDocumentDataProvider->fetchData()
#3 C:\yii\framework\zii\widgets\CBaseListView.php(105): EMongoDocumentDataProvider->getData()
#4 C:\yii\framework\zii\widgets\grid\CGridView.php(220): CGridView->init()
#5 C:\yii\framework\web\CBaseController.php(140): CGridView->init()
#6 C:\yii\framework\web\CBaseController.php(165): CountryController->createWidget()
#7 C:\web\ski\protected\views\country\admin.php(61): CountryController->widget()
#8 C:\yii\framework\web\CBaseController.php(119): require()
#9 C:\yii\framework\web\CBaseController.php(88): CountryController->renderInternal()
#10 C:\yii\framework\web\CController.php(833): CountryController->renderFile()
#11 C:\yii\framework\web\CController.php(746): CountryController->renderPartial()
#12 C:\web\ski\protected\controllers\CountryController.php(149): CountryController->render()
#13 C:\yii\framework\web\actions\CInlineAction.php(57): CountryController->actionAdmin()
#14 C:\yii\framework\web\CController.php(300): CInlineAction->run()
#15 C:\yii\framework\web\filters\CFilterChain.php(133): CountryController->runAction()
#16 C:\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
#17 C:\yii\framework\web\CController.php(1084): CAccessControlFilter->filter()
#18 C:\yii\framework\web\filters\CInlineFilter.php(59): CountryController->filterAccessControl()
#19 C:\yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter()
#20 C:\yii\framework\web\CController.php(283): CFilterChain->run()
#21 C:\yii\framework\web\CController.php(257): CountryController->runActionWithFilters()
#22 C:\yii\framework\web\CWebApplication.php(324): CountryController->run()
#23 C:\yii\framework\web\CWebApplication.php(121): CWebApplication->runController()
#24 C:\yii\framework\base\CApplication.php(135): CWebApplication->processRequest()
#25 C:\web\ski\index.php(13): CWebApplication->run()

Cannot redeclare EMongoDocument::deleteByPk()

Hi Canni,

When i run 1.3.4 version it crashes with error:
Fatal error: Cannot redeclare EMongoDocument::deleteByPk()

You put on EMongoDocument.php twice the function deleteByPk().

Query Bug ?

I'm successfully using the latest version of YiiMongoDbSuite to save to my MongoDb, so I know
its not a connectivity or other similar issue.

For some reason there seems to be a problem with querying

From the shell (version 1.8.2). If I use

$ db.products.find();
{ "_id" : ObjectId("4e60e0ccc0da53707c000000"), "display_title" : "test", "price" : "100" }
{ "_id" : ObjectId("4e617cebc0da538f72000000"), "display_title" : "test 2", "price" : "50" }
{ "_id" : ObjectId("4e617d2cc0da53b279000000"), "display_title" : "test 3", "price" : "120" }

I know that I have 3 documents in this collection.

Using YiiMongoDbSuite from my controller I use this

 $model = Product::model()->findAll();
 print_r($model);

and I get

Array
(
    [0] => Product Object
        (
            [display_title] =>
            [price] =>
            [_new:EMongoDocument:private] =>
            [_criteria:EMongoDocument:private] =>
            [_fsyncFlag:EMongoDocument:private] =>
            [_safeFlag:EMongoDocument:private] =>
            [useCursor:protected] =>
            [ensureIndexes:protected] => 1
        [_id] =>
        [_embedded:protected] =>
        [_owner:protected] =>
        [_errors:CModel:private] => Array
            (
            )

        [_validators:CModel:private] =>
        [_scenario:CModel:private] => update
        [_e:CComponent:private] =>
        [_m:CComponent:private] =>
    )

[1] => Product Object
    (
       [display_title] =>
       [price] =>
       [_new:EMongoDocument:private] =>
       [_criteria:EMongoDocument:private] =>
       [_fsyncFlag:EMongoDocument:private] =>
       [_safeFlag:EMongoDocument:private] =>
       [useCursor:protected] =>
       [ensureIndexes:protected] => 1
       [_id] =>
       [_embedded:protected] =>
       [_owner:protected] =>
       [_errors:CModel:private] => Array
           (
           )

       [_validators:CModel:private] =>
       [_scenario:CModel:private] => update
       [_e:CComponent:private] =>
       [_m:CComponent:private] =>
   )
[2] => Product Object
    (
        [display_title] =>
        [price] =>
        [_new:EMongoDocument:private] =>
        [_criteria:EMongoDocument:private] =>
        [_fsyncFlag:EMongoDocument:private] =>
        [_safeFlag:EMongoDocument:private] =>
        [useCursor:protected] =>
        [ensureIndexes:protected] => 1
        [_id] =>
        [_embedded:protected] =>
        [_owner:protected] =>
        [_errors:CModel:private] => Array
            (
            )

        [_validators:CModel:private] =>
        [_scenario:CModel:private] => update
        [_e:CComponent:private] =>
        [_m:CComponent:private] =>
    )

)

So it is returning the correct number of documents (3) but there is no
data in there. Does anyone know how to fix this or why it happens ?

Difference in explicit definition between soft and hard variables not clear

Hi,

I posted this on the yii project page too but that doesn't look too active so I thought I would post it here too.

How do you define the difference between a soft and hard variable in a class without pre-defined schema?

I have some classes in my project which use non-db variables for processing between certain methods.

It is not clear in your docs and I have looked at the source code but it just seems you set the subodcuments and just through the rest into the class as standard variables. This confuses me since ofc a document can expand and shrink, so I am wondering how you keep track of what is to be written to the DB and what is not to be written.

Thanks,

Saving nulls

Maybe i'm wrong but extensions saves null to database. Simple fix to this is:
(in EMongoEmbeddedDocument.php line 304)

if($property->isPublic() && !$property->isStatic())

change to

if($property->isPublic() && !$property->isStatic() && ($this->$name!=null || $name=='_id'))

Model Must be abstract or implement method: getCollectionName

In my IDE, in my user class I get this following warning:

Class must be declared abstract or implement method 'getCollectionName'

Which refers to the

abstract protected function getCollectionName();

in EMongoRecord. This means that your model has to have a 'getCollectionName' method because the superclass (EMongoRecord) has it declared as abstract. Renaming 'getCollectionName' to collectionName fixes this error, as well as renaming collectionName to getCollectionName in my user model. This way they are both the same name and the user model subclass properly has its own copy of that method.

I could possibly be wrong on this, but the change and what the IDE makes sense to me and an abstract method is supposed to be used in a subclass that extends it.

Issue with wrong __isset magic on embedded documents

There is a possible problem with _isset magic function. Problem appears if we don't access to embedded document via $this->embedDocName. Instead we try to check property by isset($model->embedDocName).
So I don't completely understand how I should use isset operator. Does embedded doc exists any time despite existence of corresponding field in DB?

gii-mongoCRUD generator not working with embedded documents

i have been trying to generate code for model class user with embedded document useraddress(example provided by you),mongoCRUD generator works for non embedded document.
when i try to generate code for embedded document i get the following error
array_keys() expects parameter 1 to be array, null given

on line EMongoEmbeddedDocument.php(267)
if($this->hasEmbeddedDocuments())
{
$names = array_merge($names, array_keys(self::$_embeddedConfig[get_class($this)]));
}
could you please help me out with this

Make EMongo compatible with CHtml::listData()

Hey, first let me say thanks to the great work so far. It makes me switching over to mongodb really soon in my project.

Now my concern:

lets assume i have a collection 'address' that stores my addresses and an embedded
document to a document from the collection 'country', where my countries are saved. Speaking in MySQL, this would be a 1:N relation.

Now, if i want the user to choose the country in the address _form.php, i want to present a DropDownList, like this

CHtml::activeDropDownList($addressModel, 'country', CHtml::listData(Country::model()->findAll(), '_id', 'country_title'));

This works well when i specify a own, customized primary Key for the country collection. However, if i leave it to the standard, i have ObjectId(...) objects. These can not be automatically resolved by the listData function.

There are two solutions for that: either write your own implementation of ListData, that autoMagically gets the correct id, or in my opinion better, give the ObjectId() a magic toString method, that converts to a string automatically so the CHtml::listData() provided by yii can work with it.

I hope my concern is clear. What do you think about this ?

[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.