假设我具有以下汽车制造商和相应汽车的数据库结构:
制造商:
----------------------------------
| manufacturer | founded_in | id |
|--------------|------------|----|
| Daimler AG | 1927 | 1 |
| Volkswagen AG| 1937 | 2 |
----------------------------------
Run Code Online (Sandbox Code Playgroud)
汽车:
-------------------------------------
| car | built_in | manufacturer |
|---------|----------|---------------
| C Class | 1993 | 1 |
| E Class | 1993 | 1 |
| Golf | 1974 | 2 |
-------------------------------------
Run Code Online (Sandbox Code Playgroud)
的id列manufacturers是主键,的manufacturer列cars具有相应的外键约束。
我想使用PHP产生以下JSON输出json_encode:
{
"manufacturers": {
"Daimler AG": {
"founded …Run Code Online (Sandbox Code Playgroud) 这似乎是一个非常尴尬的问题:
我正在modal.service.ts使用以下代码进行访问:
this.modalService.add('test');
我的modal.service.ts样子如下:
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class ModalService {
private modals: any[] = [];
add(modal: any) {
// add modal to array of active modals
this.modals.push(modal);
}
remove(id: string) {
// remove modal from array of active modals
this.modals = this.modals.filter(x => x.id !== id);
}
open(id: string) {
// open modal specified by id
const modal = this.modals.find(x => x.id === id);
console.log(this.modals)
console.log(this.modals[0])
//modal.open();
} …Run Code Online (Sandbox Code Playgroud) 我有桌子books,bookType它们构成1 X n关系。
books
+-----+------------------+----------+-------+
| id | title | bookType | price |
+-----+------------------+----------+-------+
| 1 | Wizard of Oz | 3 | 14 |
| 2 | Huckleberry Finn | 1 | 16 |
| 3 | Harry Potter | 2 | 25 |
| 4 | Moby Dick | 2 | 11 |
+-----+------------------+----------+-------+
Run Code Online (Sandbox Code Playgroud)
bookTypes
+-----+----------+
| id | name |
+-----+----------+
| 1 | Fiction |
| 2 | Drama |
| …Run Code Online (Sandbox Code Playgroud)