public function add($name, $value) {
        $name = trim((string)$name);
        if (empty($name)) {
            return false;
        }

        // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
        if (is_object($value)) {
            $value = clone $value;
        }

        // Make sure the option doesn't already exist
        if ($this->ydb->has_option($name)) {
            return false;
        }
        // if (false !== yourls_get_option($name)) {
            // return false;
        // }

        $table = YOURLS_DB_TABLE_OPTIONS;
        $_value = yourls_maybe_serialize($value);
        $sql  = "INSERT INTO $table (option_name, option_value) VALUES (:name, :value)";
        $bind = array('name' => $name, 'value' => $_value);
        $do   = $this->ydb->fetchAffected($sql, $bind);

        if($do !== 1) {
            // Something went wrong :(
            return false;
        }

        // Cache option value to save a DB query if needed later
        $this->ydb->set_option($name, $value);
        yourls_do_action('add_option', $name, $_value);

        return true;
    }
public function add($name, $value) {
        $name = trim((string)$name);
        if (empty($name)) {
            return false;
        }

        // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
        if (is_object($value)) {
            $value = clone $value;
        }

        // Make sure the option doesn't already exist
        if ($this->ydb->has_option($name)) {
            return false;
        }
        // if (false !== yourls_get_option($name)) {
            // return false;
        // }

        $table = YOURLS_DB_TABLE_OPTIONS;
        $_value = yourls_maybe_serialize($value);
        $sql  = "INSERT INTO $table (option_name, option_value) VALUES (:name, :value)";
        $bind = array('name' => $name, 'value' => $_value);
        $do   = $this->ydb->fetchAffected($sql, $bind);

        if($do !== 1) {
            // Something went wrong :(
            return false;
        }

        // Cache option value to save a DB query if needed later
        $this->ydb->set_option($name, $value);
        yourls_do_action('add_option', $name, $_value);

        return true;
    }
public function add ( $ name , $ value ) { $ name = trim ( ( string ) $ name ) ; if ( empty ( $ name ) ) { return false ; } // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3 if ( is_object ( $ value ) ) { $ value = clone $ value ; } // Make sure the option doesn't already exist if ( $ this -> ydb -> has_option ( $ name ) ) { return false ; } // if (false !== yourls_get_option($name)) { // return false; // } $ table = YOURLS_DB_TABLE_OPTIONS ; $ _value = yourls_maybe_serialize ( $ value ) ; $ sql = "INSERT INTO $table (option_name, option_value) VALUES (:name, :value)" ; $ bind = array ( 'name' => $ name , 'value' => $ _value ) ; $ do = $ this -> ydb -> fetchAffected ( $ sql , $ bind ) ; if ( $ do !== 1 ) { // Something went wrong :( return false ; } // Cache option value to save a DB query if needed later $ this -> ydb -> set_option ( $ name , $ value ) ; yourls_do_action ( 'add_option' , $ name , $ _value ) ; return true ; }
Add an option to the DB

@since  1.7.3
@param  string $name   Name of option to add. Expected to not be SQL-escaped.
@param  mixed  $value  Optional option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
@return bool           False if option was not added (eg already exists), true otherwise.
Add an option to the DB