tags:

views:

57

answers:

1

i m creating a view of a database in php smarty, i m confused where shoud i create that view , i just create view in a class's constructor function, now i have the problem that i m using function of that class through object of that class.... so is it true that each time that view is constructed???

example:

cityview.php

class city { function city(){ "mysql query of creating view "} function allcity() { here is some query on view } function callcity() { here is some query on view } }


now in index.php i call

$objcity=new city(); $objcity->allcity(); $objcity->callcity();


Now my question is-

Blockquote

is that VIEW is created each time when i call any function of that class??

Blockquote

if yes then tell me the way ..how do i create that view

A: 

You should definitely separate the code for the view from your application code. The database will continue to exist and remember that view even if your application shuts down. The way to create your view outside of PHP is to log into your database using the username and password that your application would use, and execute the code for any tables and views on the database through a client (sorry - don't know mysql well enough to tell you how to do that).

It sounds like you might already have an existing database, so I would talk to whoever is in charge of that DB about how to set up your view. There might be requirements for how to do source control or other release procedures you might need to be aware of.

Galghamon