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