1 一对多(One To Many) 表示一对多的关系时,在子表类 Post 中需要通过 foreign key (外键)引用父表类 User 在Post类中指定ForeignKey: class Post(db.Model): __tablename__ = 'posts' id = db.Column(db.String(45), primary_key=True) title = db.Column(db.String(255)) text = db.Column(db.Text()) p
1.关联 1)连接查询(内关联) inner join ... on 两个表连接查询 select * from students inner join classes 查询能够对应班级的学生以及班级信息 select * from students inner join classes on students.cls_id=classes.id; 按照要求显示姓名,班级 select students.*, classes.name from students inner join class
1.在application文件夹下面的config.php中打开DEBUG. 2.修改tp5/application/index/controller/Index.php内容. <?php namespace app\index\controller; //引入系统数据类 use think\Db; //引入系统控制器类 use think\Controller; class Index extends Controller { public function index() { 11 //从
<?php namespace app\controllers; use yii\web\Controller; use app\models\Customer; class CustomerController extends Controller{ //根据顾客名字查询出所有的订单信息 public function actionIndex(){ $customer = Customer::find()->where(['name'=>'zhangsan'])->one();