public static function edit($data) { $p = array('title' => array('required' => true, 'type' => 'string', 'maxlength' => 140, 'label' => 'Titulo'), 'text' => array('required' => true, 'type' => 'string', 'label' => 'Texto'), 'image' => array('required' => false, 'type' => 'thumbnail', 'label' => 'Imagen'), 'tags' => array('required' => false, 'type' => 'string', 'label' => 'Tags')); $v = new Validator(); $response = $v->validate($data, $p); if (!$response['success']) { return M::cr(false, $data, $response['msg']); } PDOSql::$pdobj = pdoConnect(); if (isset($_FILES['image']['name'])) { $response = File::up2Web($_FILES['image']); if ($response->success) { // remove old image... if (isset($data['old_image'])) { File::unlinkWeb($data['old_image']); } $image = $response->data[0]; } else { return M::cr(false, $data, $response->msg); } } else { $image = ''; } $params = array($data['title'], $data['text'], $image, $data['tags'], $data['id'], $_SESSION['userNAME']); $where = array(' id = ?', 'author = ?'); $query = "UPDATE entries SET title = ?, text = ?, image = ?, tags = ? {%WHERE%}"; PDOSql::update($query, $params, $where); return M::cr(true, array(), 'Se han actualizado los datos correctamente'); }