/** * Overwatches template and query configuration, if it's not either of those, sets it as an option * @param string $name Name of the property * @param string $value New value of the property * @return bool May return false if the template or query configuration weren't successful */ public function __set($name, $value) { if ($name == 'template') { $columns = Text::parseStringVar($value); foreach ($columns as $key => $i) { if (in_array($i, array_keys($this->vars))) { unset($columns[$key]); } } if (!Sql::hasColumns($this->table, $value)) { Kernel::Log('The template uses columns that do not exist on the ' . $this->table . ' table'); return false; } } elseif ($name == 'query') { if (!Sql::testQuery($value)) { Kernel::Log('The desired query did not run successfully. Please try another one. Your database wasn\'t affected.'); return false; } } else { $this->options[$name] = $value; } }
/** * Modifies an user's information * @param string $id_field Field to identify the user with * @param mixed $fields_mixed Fields to modify. If the value is an array, it must be formatted column => value * @param string $newvalue New value of the column * @return bool Returns true if the query was successful */ static function modifyUser($id_field, $fields_mixed, $newvalue = null) { if (is_array($fields_mixed)) { if (!Sql::hasColumns('accounts', array_keys($fields_mixed))) { return false; } } else { if (!Sql::hasColumns('accounts', array($fields_mixed))) { return false; } } $q = Sql::Update('accounts', array($fields_mixed => $newvalue), 'WHERE ' . self::$id_field . ' = \'' . $id_field . '\''); return $q; }