Friday, April 30, 2010

Re: Table Naming convention problem

that is not my problem. who to use the table name in controller my
table name is "adb_campaign"(we can not change the table) what is the
model, view and controller and how to use it.

thanks sir

On Apr 30, 2:00 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> I was wrong about something - your view is called mycampaigns, not mycampaign - sorry. However, it looks like you are getting back a list of campaigns rather than just one. So I would change the function code to:
>
> function mycampaigns() {
>         $campaigns = $this->Campaign->find('all');
>         $this->set('campaigns',$campaigns);
>
> }
>
> Notice the pluralisation of the the campaignS variable, which is what your view is looking for. You can shorten it further too:
>
> function mycampaigns() {
>         $this->set(
>                 'campaigns',
>                 $this->Campaign->find('all')
>         );
>
> }
>
> Jeremy Burns
> jeremybu...@me.com
> (Skype) +44 208 123 3822 (jeremy_burns)
> (m) +44 7973 481949
> (h) +44 208 530 7573
>
> On 30 Apr 2010, at 09:53, Jeremy Burns wrote:
>
>
>
> > It is rarely a good idea to stray from conventions (http://book.cakephp.org/view/22/CakePHP-Conventions) if you can avoid it. Is it too late to re-factor your database? Assuming it is...
>
> > You are putting your prefix into the variable that is intended to hold the name of the controller/model.
>
> > Try:
>
> > Model:
> > var $name = 'Campaign';
> > var $useTable = 'campaign';
> > var $tablePrefix = 'adb_';
>
> > //ideally you'd call the table campaigns, then wouldn't need the $useTable or tablePrefix variables
>
> > Controller:
> > var $name = 'Campaigns';
>
> > I'd recommend getting rid of your $uses array because it will hit performance - look up Associations-Linking-Models-Together.
>
> > Your view folder should be called campaigns.
>
> > The 'mycampaign.ctp' view you have created will be rendered when you access the controller function 'mycampaign'.
>
> > Jeremy Burns
> > jeremybu...@me.com
>
> > On 30 Apr 2010, at 09:40, Master Ram wrote:
>
> >> HI. all i am new to cakephp
>
> >> i have table name called: adb_campaign
>
> >> my contorller is:
> >> my controller Name: compaigns_controller.php
>
> >> <?php
> >> class CompaignsController extends AppController {
>
> >>    //var $tablePrefix = 'adb_';//var $name = "Users";
> >>    var $name = 'adb_'
>
> >>    var $uses=array('Client','User','Campaign');
> >>    //var $uses=array('User');
>
> >>    var $helpers = array('Html', 'Form');
> >>    function mycampaigns()
> >>    {
> >>        $campaigns = $this->Campaign->find('all');
> >>        $this->set('campaign',$campaigns);
> >>    }
>
> >> }
> >> ?>
>
> >> my modle Name: campaign.php
>
> >> <?php
> >> class Campaign extends AppModel {
>
> >>   // var $tablePrefix = 'adb_';
> >>    var $useTable ='adb_'
>
> >> }
> >> ?>
>
> >> in the view folder name: campaign
>
> >> mycampaigns.ctp
>
> >> <?php
> >>                                                        $a = array();
> >>                                                        $i=1;
>
> >> foreach( $campaigns as $campaign ):
> >>                                                        $a[$i] =
> >> $campaign['Campaign']['jobno'];
> >>                                                        $i++;
> >>                                                        endforeach;
> >>                                                        echo $form-
> >>> select('campaign ', $a, 0,
> >>                                                        array('style'
> >> => 'width: 50%'),false);
> >>                                                        ?>
>
> >> where i made the mistake please help me
>
> >> regards:
> >> Master
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> >> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> >> To post to this group, send email to cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: