$item = "{$item} = :{$item}"; }); $contents[] = ""; $contents[] = "\tfunction update() {"; $contents[] = "\t\t\$stmt = \$this->conn->prepare("; $contents[] = "\t\t\t'UPDATE {$table} SET"; $contents[] = "\t\t\t\t" . implode(", ", $fields); $contents[] = "\t\t\t\tWHERE id = :id;"; $contents[] = "\t\t\t);'"; $contents[] = "\t\t);"; foreach ($this->fields as $field) { $contents[] = "\t\t\$stmt->bindValue(':{$field}', \$this->{$field}, \\PDO::PARAM_STR);"; } $contents[] = "\t\t\$stmt->bindValue(':id', \$this->id, \\PDO::PARAM_INT);"; $contents[] = ""; $contents[] = "\t\treturn \$stmt;"; $contents[] = "\t}"; $contents[] = ""; $contents[] = "\tfunction load(\$row) {"; foreach ($this->fields as $field) { $contents[] = "\t\t\$this->{$field} \t\t= \$row['{$table}__{$field}'];"; } $contents[] = "\t}"; $contents[] = "}"; print_r($contents); file_put_contents("{$path}/{$this->name}.php", implode("\n", $contents)); } } $builder = new ClassBuilder($argv); $builder->run();