Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8754755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:42:02+00:00 2026-06-13T13:42:02+00:00

I’m a beginning PHP developer. I have an app I’ve written that I would

  • 0

I’m a beginning PHP developer. I have an app I’ve written that I would like to rewrite using Yii. Most of it is pretty straight-forward so far but I have one view in the current app that the company using the app loves and I doubt they will want it to change.

In this view there is a form that looks a lot like a spreadsheet (lots of rows and columns to input quantities). The first column of the form is the name of an item, the other 7 columns represent the quantity of the item for each day of the week. Each cell represents an order for the row item and column date and has an input box.

In the database, each individual order is a row in the database and there is only one date column for each order obviously. Rigging up the view was easy enough in pure PHP, but I have no idea how to do this with Yii.

Yii’s CGridView seems to map database columns to columns in the data grid table. I can’t figure out how to have 7 columns in the grid view, one for each day of the week when the database only has one date column. According to the documentation in CGridView each row corresponds to one data item. In my view each row would need to be 7 data items.

The question(s):
Is there any way to do this with Yii right now?
Would writing an extension be a good solution?
Is Yii not going to help me at all with this view? Or is there something besides CGridView?
If Yii can do it, where do I start? Something in CActiveDataProvider, extending CDataColumn, tweaking the model?

I’m not really sure how to proceed, and don’t want to get too far into porting the app to Yii if it’s not appropriate. Hopefully this was clear enough to convey what the issue is. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:42:03+00:00Added an answer on June 13, 2026 at 1:42 pm

    One option would be to create some relations for your items table. I assume they are already related to the order table. You could create a STAT relation for each day of the week in your items model, for example:

    public function relations()
    {
        return array(
            ...
            'sundayOrderCount' => array(self::STAT, 'Orders', 'item_id', 'condition'=>'DAYNAME(`order_date`) = "Sunday"',
            ...
        );
    }
    

    (where item_id is the fk for Items in your Orders table, and order_date is a timestamp in your Orders table of when the order was made)

    In the example above you should be able to grab all the items from the table and get each items total sales for Sunday like so

    $model->sundayOrderCount;
    

    And pop in a CGridView like so:

    $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'item-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(
            'name',
            array(
                'header'=>'Sunday Sales',
                'value'=>'$data->sundayOrderCount',
            ),
        ),
    ));
    

    Not tested it, but I hope that gives you something to go on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.