artista_id = $data["artista_id"]; if ( isset( $data["nombre"])) $this->nombre = $data["nombre"]; if ( isset( $data["descripcion"])) $this->descripcion = $data["descripcion"]; } public static function getById( $artista_id ) { $result = ConnectionFactory::getFactory()->getByArray("artista", array("artista_id"), array($artista_id), "Artista"); return $result["object"]; } public static function getList($page) { $rows = getAdminCookieValue("ARTISTAS_PER_PAGE"); if (!$rows || !ctype_digit($rows)) $rows = DEFAULT_ROWS; $limit1 = ($page-1)*$rows; $limit2 = $rows; $result = ConnectionFactory::getFactory()->getList("artista", "Artista", " $limit1,$limit2 ", null, null ); return (array("results" => $result["list"], "totalRows" => $result["totalRows"])); } public static function getAllList() { $result = ConnectionFactory::getFactory()->getList("artista", "Artista", null, null, null ); return (array("results" => $result["list"], "totalRows" => $result["totalRows"])); } public function delete() { $result = ConnectionFactory::getFactory()->delete("artista", "artista_id", $this->artista_id); } public function validateBeforeInsert(){ $error = false; if ($this->nombre == '' ) $error[] = 'ARTISTA_ERROR_1'; return $error; } public function insert() { $error = $this->validateBeforeInsert(); $id = "0"; if (!$error){ $fields = array("nombre","descripcion"); $result = ConnectionFactory::getFactory()->insert($this, "artista", $fields); if ($result["error"]) $error = array($result["error"]); $id = $result["id"]; } return array("error" => $error, "id" => $id); } public function update() { if ( is_null( $this->artista_id ) ) trigger_error ( "Update error", E_USER_ERROR ); $error = $this->validateBeforeInsert(); if (!$error){ $fields = array("nombre","descripcion"); $error = ConnectionFactory::getFactory()->update($this, "artista", $fields, "artista_id"); if ($error) $error = array($error); } return array("error" => $error, "id" => $this->artista_id); } } ?>