PHP list count

jh

Member
Hi

I want to use php to insert a count of records from a list with a 'where' statement using a value from this list. I have done this in calc but I want to use php to store the values.

I can do this fine when the count is using data from another table however I keep running into problems when wanting to count from the list itself.

I have used a subquery but can not work out how to filter the list ('where'). I have got it this far but all my attempts at using a 'where' statment have failed.

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->update('pattern_table')
->set('co_count = (select mycount from (SELECT count(*) as mycount from pattern_table) as d)');
$myDb->setQuery($myQuery);
$myDb->execute();

If someone could kindly assist I would be very grateful.

Kind Regards
 
Hi!

It's a bit confusing what exactly are you trying to do. In the code above you are updating pattern_table.co_count with some value from the same table?

Anyway, assuming you are updating the value in list with php form plugin, you can use placeholders, e.g:
->where('myvalue = ' . $myDb->quote('{mytable___myvalue_raw}'))
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top