sum() static public method

Gets the sum of values in a column of a table
static public sum ( string $table, string $column, mixed $where = null ) : mixed
$table string The table name
$column string The name of the column
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
return mixed
Ejemplo n.º 1
0
 public function testSum()
 {
     $this->assertEquals(6, db::sum('users', 'id'));
 }
Ejemplo n.º 2
0
        //必须return
    }
    //当把对象当成函数调用时
    function __invoke($arg1, $arg2, $agr3)
    {
        //......
        return __FUNCTION__ . $arg1 . $arg2;
    }
}
$db = new db();
$db->where('where id>10')->limit('limit 10')->select('select * from test');
//调用、设置不存在的属性
$db->name = 'zhang';
echo "\n" . $db->name;
//调用不存在的方法(、静态)
$db->sum('a', 123);
$db::add('b', '456');
//对象当成字符串
echo $db;
//对象当成函数
echo $db('a', 'b', 'c');
//设计模式开始
namespace design;

use struct\db;
/**
 *工厂模式 (要什么对象就返回什么类的对象)
 *好处:更改类名只需更改一处(其他是设计模式的基础)
 */
class Factory
{