ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Chronoforms 7 - Any way to get row counts on a query?

gurucachoo 22d ago
Running Chronoforms 7 on Wordpress. Any somewhat simple way I can make a DB call and get a count of records returned back?
I'm able to figure out making the call and getting back the responses, but I'm trying to limit by a specific field and if the count comes back more than 3 times, stop the form processing and give a message.

So far using Read Data and specifying the Where clauses works great.
I've tried using the SQL Data action and it bombs my site whenever I use it.

Can anyone help. I've been racking my brain.
webbusteruk 20d ago
You can do get row counts easily with some PHP code.

If you're using a Read Data function, {fn:read_data} will return {var:read_data} as an array. Just use PHP to count the items in the array. To retrieve {var:read_data} in PHP code, use:

$array = $this->get("read_data.Model");

echo count($array);

The exact code depends on what your returned array look like from {fn:read_data}. However, this is AFTER the DB query has been made and processed.

From your post it sounds like you want it to stop WHILE doing the DB query if the count reaches 3? If you want to do it this way, you'll need to code the whole query in PHP.
You need to login to be able to post a reply.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com