Yii Framework Forum: Gii generated database code Questions - Yii Framework Forum

Jump to content

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

Gii generated database code Questions Rate Topic: -----

#1 User is offline   jkofsky 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 535
  • Joined: 17-May 10
  • Location:Pensacola, Florida

  Posted 17 May 2010 - 03:24 PM

I am NEEEEWWWWWW to frameworks, but have a fare amount of knowledge in PHP/HTML/CSS

I successfully installed Yii, generated WebApp, and got Gii to generate Model/CRUD. Now what? :)

Actually my question is How/where/why does the generated code works as it does?

I generated a model called employees, when I go to this page I get everybody. I can see this a default, but need to change it to show only `IsActive`=1; I just can't find the "sql" that querys the database to be able to modify it, OR what/where to change some array() for the default action to set the filter.

Now the Huh/What question: In the admin (Manage) code the "Complete List" of employees is ONLY the ones that match the mySQL defined default values. If I am Managing my list of employees, I probably want to see ALL of them not just the ones that don't have there Home Number set. (Actually I default HomeNumber to 'See Cell', but you get what I mean.)

Thanks in advance.
Jeff
Do, or do not. There is no 'try.' Jedi Master Yoda
0

#2 User is offline   BornToDrink 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 31-December 09
  • Location:Bulgaria

Posted 17 May 2010 - 03:36 PM

Go to protected/controllers/EmployeeControllers.php

Find this method:
	public function actionIndex()
	{
	    $this->render('index',array(
	        'dataProvider'=>$dataProvider,
	    ));
	}


And add criteria:

	public function actionIndex()
	{
	    $dataProvider=new CActiveDataProvider('Employees', array(
                'criteria'=>array(
                    'condition'=>'IsActive = 1',
                )
            ));
	    $this->render('index',array(
	        'dataProvider'=>$dataProvider,
	    ));
	}


But about this question:
"Actually my question is How/where/why does the generated code works as it does?"
The 'solution' is maybe here:
http://www.yiiframew...guide-1.1.2.pdf
:)
0

#3 User is offline   jkofsky 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 535
  • Joined: 17-May 10
  • Location:Pensacola, Florida

Posted 17 May 2010 - 03:45 PM

View PostBornToDrink, on 17 May 2010 - 03:36 PM, said:


But about this question:
"Actually my question is How/where/why does the generated code works as it does?"
The 'solution' is maybe here:
http://www.yiiframew...guide-1.1.2.pdf
:)


Thanks for the reply to question will try when I get back.

As for the above:
I looked through that document but still couldn't get a good idea of where to put my includes from the descriptions in Sec. 2.10.5 Directory.

Thanks again

Sorry wrong post question :blink:

This post has been edited by jkofsky: 17 May 2010 - 04:10 PM

Do, or do not. There is no 'try.' Jedi Master Yoda
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