Skip to content

Instantly share code, notes, and snippets.

@damienwebdev
Last active March 27, 2017 14:12
Show Gist options
  • Save damienwebdev/36c500da750eda2feed875170378be44 to your computer and use it in GitHub Desktop.
Save damienwebdev/36c500da750eda2feed875170378be44 to your computer and use it in GitHub Desktop.
<?php
use MyModel;
class ExampleClass {
public static function sumMyData(){
$sum = 0;
$myIdsArray = [];
$myIdsArray = MyModel::getMyListOfIdsFromDb();
$collection = MyModel::getCollection($myIdsArray);
foreach($object in $collection){
$sum = sum + $object->value;
}
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment