Skip to main content
Participant
June 16, 2009
Question

Binding cfdiv to cfc object?

  • June 16, 2009
  • 1 reply
  • 454 views

I have been using cfcs recently, and I'm wondering if there's a way to bind cfdivs to cfc objects, instead of just the cfc.

My cfc retrieves a lot of records from the database, and pages them manually (not using cfgrid). If there's a way I could store the results from the big search, just for that page, like a cfc object instance, and then just query those results for each page, I think it would be a lot faster instead of having to get the big set of results over and over. I have contemplated using session variables but I don't know much about them. I also don't really need to store those records for the whole session.

Thanks in advance.

    This topic has been closed for replies.

    1 reply

    Dileep_NR
    Inspiring
    June 18, 2009

    Hi,

         Please try the following,

    create procedure with neccesary changes

    if you pass 0 and -99 then you will get the whole result

    if you pass 0 and 10 then you will get records from 1 to 10;

    if you pass 1 and 10 then you will get records from 11 to 20;........

    ---------------
    CREATE PROCEDURE <<procname>>(
      pagesize int
      ,pageindex int
    )
    BEGIN
      DECLARE FirstRec,LastRec INT;

      DROP TEMPORARY TABLE IF EXISTS CommentTempTable;
      CREATE TEMPORARY TABLE CommentTempTable
      (
        id INT NOT NULL AUTO_INCREMENT primary key
        ,commentid int
        ,comment varchar(3000)
        );

      INSERT INTO CommentTempTable
      (
        commentid
        ,comment
       
        )
        select
            <<tablename>>.commentid
            ,<<tablename>>.comment

            ,<<tablename>>.dateentered
    from <<tablename>>
            ;


      SET FirstRec = pageindex * pagesize;  /* 0 based index  */
      SET LastRec = (pageindex + 1) * pagesize + 1;


      IF (pagesize = -99) then

        SELECT
            commentid
            ,comment      
          FROM
            CommentTempTable;
      ELSE
          SELECT
            commentid
            ,comment
           
          FROM
              CommentTempTable
          WHERE
              ID > FirstRec AND ID < LastRec;

        SELECT COUNT(*) as RowCount FROM CommentTempTable;

      END IF;

      DROP TABLE CommentTempTable;

    END $$

    ----------------

    This stored procedure returns two result

    1) selected records

    2) total record count