1

I want to make a Web Service for my site, I need to echo a JSON array

I am using this code:

 $dataProvider=new CActiveDataProvider('AmakenPlaces',array(
                     'criteria'=>array(
                                                'condition'=>'admin_active=1',
                                )));
        $dataProvider->pagination->pageSize =10;
        $dataProvider->pagination->pageVar = 'page';

But how can U make the following:

echo CJSON::encode($dataProvider);

Echo a JSON array from my database ... I am using $dataProvider for pagination feature.

1 Answer 1

3

Try calling the getData() method on your data provider:

echo CJSON::encode($dataProvider->getData());

Source: example at the top of http://www.yiiframework.com/doc/api/1.1/CActiveDataProvider

Sign up to request clarification or add additional context in comments.

1 Comment

getData returns only a single row, or am I making a mistake?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.