php mysql coherent operation

不言
Release: 2023-03-23 19:00:01
Original
1490 people have browsed it

The content shared with you in this article is the coherent operation of php mysql, which has a certain reference value. Friends in need can refer to it

where('id=1 and name="wangjialin"')
//            ->find());

        // 参数为数组
        $map = [
//            'id'=> 2,
//            'name' => 'zhangsan',
//            'age' => ['>' , 10 ],
//            'name' => ['like' , '%zhang%'],
            'age' => ['between' , '14,18']
        ];
//        dump(Db::name('user')->where($map)->select());

        // field order limit
//        dump(Db::name('user')
//            ->field('id , name  as username, age')
//            ->select());
//        dump(Db::name('user')
//            ->field(['id' , 'name as username' , 'age' , 'sex'])
//            ->order('id desc')
//            ->limit(1)
//            ->select());

        // group having
//        dump(Db::name('user')
//            ->field(['sum(age) as all_age'])
//            ->group('password')
//            ->having('all_age > 50')
//            ->select());

        // 聚合操作count avg sum min max
        dump(Db::name('user')->count());
        dump(Db::name('user')->sum('age'));
        dump(Db::name('user')->avg('age'));

        // 获取最近的执行的sql语句
        dump(Db::name('user')->getLastSql());
    }


}
Copy after login

Related recommendations:

PHP Methods to connect to mysql-mysqli and PDO


The above is the detailed content of php mysql coherent operation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!