| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function save() |
||
| 24 | { |
||
| 25 | if ($this->isNew()) { |
||
| 26 | // insert |
||
| 27 | $statement = $this->dbObject->prepare(<<<SQL |
||
| 28 | INSERT INTO userdomain ( |
||
| 29 | user, domain |
||
| 30 | ) VALUES ( |
||
| 31 | :user, :domain |
||
| 32 | ); |
||
| 33 | SQL |
||
| 34 | ); |
||
| 35 | |||
| 36 | $statement->bindValue(":user", $this->user); |
||
| 37 | $statement->bindValue(":domain", $this->domain); |
||
| 38 | |||
| 39 | if ($statement->execute()) { |
||
| 40 | $this->id = (int)$this->dbObject->lastInsertId(); |
||
| 41 | } |
||
| 42 | else { |
||
| 43 | throw new Exception($statement->errorInfo()); |
||
|
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 | else { |
||
| 47 | // insert / delete only, no updates please. |
||
| 48 | throw new Exception('Updating domain membership is not available'); |
||
| 49 | } |
||
| 85 | } |