Tuesday, September 21, 2010

Re: How to Create and use dummy table in cakephp

On Tue, Sep 21, 2010 at 1:03 AM, rakeshyadav rakeshyadav
<rakeshyadav.php@gmail.com> wrote:
> Hi All,
>
>            In my application i am trying to use one table it is dummy table
> dynamicaly created by me and push some data and do some operations in that
> and finely i want to delete that table form database.Here i dont have chance
> to create modal for that table below i will give u php related stuf please
> help me in cake
>
>                   $sql = "CREATE VIEW filtered_campaign_stores
>                                AS
>                                 SELECT DISTINCT store_id, campaign_id
>                                 FROM campaign_store_dates
>                                 WHERE date BETWEEN '$weekStartDate' AND
> '$weekEndDate'
>                                 AND store_id IN ($storeIdList)";
>                         $this->sql($sql);
>  dummy table is : filtered_campaign_stores
>
>                         $sql = "SELECT store_id, COUNT(campaign_id) as count
>                                 FROM filtered_campaign_stores
>                                 GROUP BY store_id";
>                       $campaigns = $this->select($sql);
> After doing the above operation i am running the below query
>
>                       $sql = "DROP VIEW filtered_campaign_stores";
>                         $this->sql($sql);
>
> HELP ME HOW TO RUN DYNAMIC TABLE WITH CREATION OF MODAL.
>


This seems like more trouble than it's worth. You could do something like this:

$this->find(
'all',
array(
'conditions' => array(
'store_id' => $storeIdList,
'date BETWEEN ? AND ?' => array(
$weekStartDate,
$weekEndDate
)
),
'contain' => array(
'Store',
'Campaign'
)
)
);

That's not precisely what you're doing but you could modify it to suit
your needs. It's not clear to me what your model is here so you should
maybe add that in to the conditions keys (eg. 'MODEL.date',
'MODEL.store_id', etc.)

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: