How can I pull data from an extra table in my database?
Lets say my table is called "clients", and my column is "name", how can I pull the data to show it?
Thanks a lot!
How can I pull data from an extra table in my database?
Lets say my table is called "clients", and my column is "name", how can I pull the data to show it?
Thanks a lot!
Yes - Yii uses an MVC approach so you need to have a Model (usually represents a row in your database) and a controller (allows users to perform actions against that model - view, update etc)
The easiest way is to use the Gii code generator to build your model and controller.
3265
[list=1][]create your Model (database table must be created already)[]create your CRUD (Create, Read, Update, Delete) operations[/list]
After generating your CRUD, the Gii generator should provide you with a sample link to test; I think…
Good luck - Yii has a much more flexible architecture than most CMSes but a bit of a learning curve for newcomers. Once you get the hang of it, it’s a piece of cake.
Matt
Thanks so much for your help. How do I get to the code generator? I’m very dumb with this lol. I noticed there’s a generator folder inside the gii folder… am I supposed to open something inside of that or is it a webbased generator? Or how do I get to the menu in the screencap you posted?
If you’re working on localhost:
You do have to setup the config for it in your main config file. See the link in the 1st post I sent.
My code looks like this.
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'blahblah',
),
),
Matt
Thanx so much for the help so far. I’m pretty sure I’ll get a hang of it, as soon as I can get into the GII generator… but I’m not having luck yet. I added the code to my config file, however, my website then appeared blank, so I removed it again.
The script uses a database.php file to connect to the db, and not a config file. This is what it looks like:
I tried placing it above or underneath the, but didn’t work… is it supposed to be inside the brackets or something?
Also, the place where I need to enter a password in the code you gave… must it be the same as my db? Or is it a new one I enter to access the GII generator?
When it comes to the URL of the gii generator… I don’t know if it’s cause I don’t have the config info set up yet, but neither one of the URLs are working. I’m not sure if it’s cause the site is running on a script, but right now the folder structure is like this: The script is in the root, and then there’s a “yii” folder, and inside it is a “gii” folder. Not sure if my folder structure changes the URL or something?
I really really appreciate your help! Thank you!
@cp11 as you are posting in the Yii 1.0.x section, is your app created with that version of Yii ?
Because Gii was added only later on Yii 1.1.x
Can you please post a sample internal link the site uses? Also paste your config file - minus the usernames/pwds
If all else fails, post your DB schema and I’ll whip up the Model, Controller, and Views for you.
Matt
[color="#008000"]NOTE: moved to proper section (General Discussion for Yii 1.1.x instead of 1.0.x)[/color]