本文整理汇总了PHP中app\models\Person::sum方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::sum方法的具体用法?PHP Person::sum怎么用?PHP Person::sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Person
的用法示例。
在下文中一共展示了Person::sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
require_once __DIR__ . '/vendor/autoload.php';
// Require the person class file
// require("Person.class.php");
// Instantiate the person class
use App\Models\Person;
$person = new \App\Models\Person();
// Create new person
$person->Firstname = "Kona";
$person->Age = "20";
$person->Sex = "F";
$creation = $person->Create();
// Update Person Info
$person->id = "4";
$person->Age = "32";
$saved = $person->Save();
// Find person
$person->id = "4";
$person->Find();
d($person->Firstname, "Person->Firstname");
d($person->Age, "Person->Age");
// Delete person
$person->id = "17";
$delete = $person->Delete();
// Get all persons
$persons = $person->all();
// Aggregates methods
d($person->max('age'), "Max person age");
d($person->min('age'), "Min person age");
d($person->sum('age'), "Sum persons age");
d($person->avg('age'), "Average persons age");
d($person->count('id'), "Count persons");