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.

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()

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;

[QUOTE=robydago;38837]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()[/QUOTE]

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.functions.recordcount.html

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 )-:

if ($rcount==0){

forgive me!

Hello,

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

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

Never used this way, but, use sc_select instead. sc_lookup returns an array, sc_select is the macro returning an ADODBRecordset

sc_select(dataset,“SELECT * FROM DokumentiMape WHERE Podjetje_v_uporavljanju = ‘[Mapica_podjetje_v_upravljanju]’”);
{OznakaMape} = {dataset}->RecordCount();

How to get row numbers? I must get total row number.:frowning:

Please help!

It works perfectly!

It was my mistake. Sorry!

1 Like