Load data from mySQL DB in a static page

Hello!

I’m trying to load data from the mysql db to a static page.I’ve already created the DB,assigned it to a yii project in config file. Now I need to load this data into a var and send it to a static page. If I’ve wanted to send to an ordinary page - I would write smth like this


$this->render('about', $content);

So the main question is - how to send data to a static page?

Second question : how to load data from mysql db to a variable! For example db name: testdb, table name: alltext.

I want to load text from content cell of alltext table where id = 1. Thanks in advance! ::)

if you send some variable… then this page is not static…

Hmmm…someone said static pages could be used for terms and agreement page, for example! But what if it’s text needs to be edited?

I thought I could just paste a variable to it somehow. :huh:

Edited?

In the first post you wrote how to pass a variable to a view…

Example for the terms and agreements… in the SiteController.php you put




	public function actionTerm()

	{

		$this->render('term',array(

			'note'=>'This is a custom note...'),

		));

	}



that will render the view file protected/views/site/term.php, where you can use the $note variable

thanks! I see now - that static page is not an option. It’s just that I feel weird writing several similar actions with only two changing things :

  1. value of $content variable

  2. page to render(term,about etc…)




public function actionTerm()

{

        $content = 'Terms content';

        $this->render('term',array(

                'content'=>'$content'),

        ));

}


public function actionAboutUs()

{

        $content = 'About us content';

        $this->render('about',array(

                'content'=>'$content'),

        ));

}



I’m new to Yii and MVC structure in general, so I may express myself incorect sometimes.

You can use the same action and a GET parameter for selecting content (in the example above).

/Tommy