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

  • SEARCH
  • Home
  • 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 8310737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:34:12+00:00 2026-06-08T19:34:12+00:00

I have a simple CFC class that handles CRUD on a Product – Product.cfc.

  • 0

I have a simple CFC class that handles CRUD on a Product – Product.cfc.

I am extending the class to allow for additional properties based on the application – for instance CartProduct.cfc extends Product.cfc in order to allow for a Quantity property to be included.

In the Base Product.cfc class, I first pass in an ID, and use the ID in my read() method to retrieve the data from the database:

<cffunction name="read" returntype="Query">
    <cfquery name="qData" datasource="mydb">
        SELECT    description
        FROM      mySKUTable
        WHERE     id = '#VARIABLES.Sku#'
    </cfquery>

    <cfreturn qData />
</cffunction>

<cffunction name="setSku" returntype="Product">
    <cfargument name="Sku" type="String" required="true" />
    <cfscript>
        var qData = QueryNew("");

        VARIABLES.Sku = ARGUMENTS.Sku;

        qData = read();

        VARIABLES.description = qData.description;
    </cfscript>
</cffunction>

I want to extend this in CartProduct.cfc to retrieve and set the Quantity from a different table using the read() method:

<cffunction name="read" returntype="Query">
    <cfquery name="qData" datasource="mydb">
        SELECT    quantity
        FROM      myCartTable
        WHERE     id = '#VARIABLES.Sku#'
    </cfquery>

    <cfreturn qData />
</cffunction>

<cffunction name="setSku" returntype="Product">
    <cfargument name="Sku" type="String" required="true" />
    <cfscript>
        var qData = QueryNew("");

        THIS = SUPER.setSku(Sku);

        qData = read();

        VARIABLES.quantity = qData.quantity;
    </cfscript>
</cffunction>

When I do this, only the extended read() is called. This is fine, this is as designed. However, I’m looking for a way to have BOTH read() methods called, so I can first set the properties in the base class, and then set the Properties in the extended class.

Any thoughts on this?

p.s. I know I’m not using CFQUERYPARAM or validating my inputs, etc. I left that crap out in order to keep this simple, so please don’t give me those suggestions right now.

  • 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-08T19:34:13+00:00Added an answer on June 8, 2026 at 7:34 pm

    Ok, here’s what I came up with:

    Instead of returning a Query from the read() method, I’m converting the Query row to a Struct and returning the Struct. That way I can call SUPER.read() from within read() and then copy the the keys and values from the parent Struct into the new Struct at every level. It’s a little more code, but it gets the job done.

    <cffunction name="read" returntype="Struct" output="false">
        <cfscript>
            var _qData = QueryNew("");
            var _properties = SUPER.read();
        </cfscript>
    
        <cfquery>
        ...
        </cfquery>
    
        <cfscript>
            StructAppend(
                _properties,
                REQUEST.UDFLib.Query.queryRowToStruct(_qData)
                );
    
            return _properties;
        </cfscript>
    </cffunction>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following, very simple CFC that I'm calling with jQuery. It works
I have a couple of places that have some code like this: <cfinvoke component=#application.path#cfc/eval_faculty
I have simple queue worker based on standard AMQP Class from PHP. It works
I have simple class with width and height member fields which define number of
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
i have simple QStandardItemModel that holds the date to show in QTreeview when i
I have simple aspx page that has a form and a input field in
So, given that I have an instance of this component: foo.cfc <cfcomponent> <cffunction name=locateMe>
I have a page that is posting a JSON to a cfc, and getting

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.