Announcement

Collapse
No announcement yet.

count the number of rows from result set of sc_select macro

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • count the number of rows from result set of sc_select macro

    hi,
    i tried this
    sc_select(dataset,"select id,name from users");
    $count=count({dataset});
    echo $count;
    o/p=1 (but result rows are more than 1)

    using sc_lookup i'm getting correct result.

    how to get correct count result using sc_select() macro.
    vijay

  • #2
    If I remember correclty sc_select returns an adodb object so you should be able to use its methods\properties:

    http://phplens.com/lens/adodb/docs-adodb.htm


    Record count should be:
    {dataset}->RecordCount()

    Comment


    • #3
      Because sc_select return an AdoDBRecordset Object, instead an array like sc_lookup.
      An ADODBRecordset contains a pointer to DB with an assoc array.

      You can obtain the data you need with:
      echo {dataset}->_numOfRows;
      /Giuseppe

      Professional Scriptcase Services
      Some Customers opinions

      Comment


      • #4
        Originally posted by robydago View Post
        If I remember correclty sc_select returns an adodb object so you should be able to use its methods\properties:

        http://phplens.com/lens/adodb/docs-adodb.htm


        Record count should be:
        {dataset}->RecordCount()
        Exactly. I was searching for this method but I didn't found it. Where did you saw it? I searched a lot in documentation.....

        EDITED:
        Nevermind, obviously I need glasses.
        http://phplens.com/adodb/reference.f...cordcount.html
        Last edited by Giu; 07-22-2015, 04:46 AM.
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          Hi,

          is this a numeric output?
          Tests like
          $rcount = {dataset} ->RecordCount();
          if ($rcount=0){
          echo "No records found" ;
          } else
          {
          // dosomething
          }

          do not seem to work )-:
          Last edited by etsoft; 08-04-2015, 02:53 PM.

          Comment


          • #6
            if ($rcount==0){

            Comment


            • #7
              forgive me!

              Comment


              • #8
                Hello,

                does the command $rcount = {dataset} ->RecordCount(); doesnt work on Scriptcase anymore? I am getting an error.

                Code:
                sc_lookup(dataset,"SELECT item_number, pn, description FROM invoice_items WHERE invoice_id='[invoice_id]'");
                $rcount = {dataset} ->RecordCount();
                Fatal error: Call to a member function RecordCount() on array in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\NSEOS\pdf report_invoices_tcpdf\pdfreport_invoices_tcpdf_gri d.class.php on line 756

                Comment


                • #9
                  Never used this way, but, use sc_select instead. sc_lookup returns an array, sc_select is the macro returning an ADODBRecordset
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment

                  Working...
                  X