| Conditions | 5 |
| Paths | 9 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function sql():string{ |
||
| 22 | |||
| 23 | if(empty($this->name)){ |
||
| 24 | throw new QueryException('no name specified'); |
||
| 25 | } |
||
| 26 | |||
| 27 | list($charset) = explode('_', $this->collate); |
||
| 28 | |||
| 29 | $collate = 'CHARACTER SET '.$charset; |
||
| 30 | |||
| 31 | if($charset !== $this->collate){ |
||
| 32 | $collate .= ' COLLATE '.$this->collate; |
||
| 33 | } |
||
| 34 | |||
| 35 | $sql = 'CREATE DATABASE '; |
||
| 36 | $sql .= $this->ifNotExists ? 'IF NOT EXISTS ' : ''; |
||
| 37 | $sql .= $this->quote($this->name); |
||
| 38 | $sql .= $this->collate ? ' '.$collate : ''; |
||
| 39 | |||
| 40 | return $sql; |
||
| 41 | } |
||
| 42 | |||
| 44 |