| Conditions | 3 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | public function insert($object) { |
||
| 38 | $db = classSupernova::$gc->db; |
||
| 39 | |||
| 40 | $query = array(); |
||
| 41 | foreach ($object->getRow(false) as $fieldName => $fieldValue) { |
||
| 42 | $fieldValue = $db->db_escape($fieldValue); |
||
| 43 | $query[] = "`{$fieldName}` = '{$fieldValue}'"; |
||
| 44 | } |
||
| 45 | |||
| 46 | $query = implode(',', $query); |
||
| 47 | if (empty($query)) { |
||
| 48 | // TODO Exceptiion |
||
| 49 | return 0; |
||
| 50 | } |
||
| 51 | |||
| 52 | $db->doquery("INSERT INTO `{{" . $object::$tableName . "}}` SET " . $query); |
||
| 53 | |||
| 54 | // TODO Exceptiion if db_insert_id() is empty |
||
| 55 | $dbId = $db->db_insert_id(); |
||
| 56 | $object->setDbId($dbId); |
||
| 57 | |||
| 58 | return $dbId; |
||
| 59 | } |
||
| 60 | |||
| 62 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.