📕
Sprnva Docs
  • Introduction
  • What's New?
  • Installation
    • Requirements
    • Download Sprnva zip no composer required
    • Install Sprnva Using Composer
    • Setup Config
  • Deployment
  • File Structure
  • Database
    • Select
    • SelectLoop
    • Insert
    • Update
    • Delete
    • Query
    • Seeder
    • Paginate
    • With
    • andFilter
    • withCount
    • get
  • Query Builder
  • Migration
    • INSTANCES
      • NEW
      • RENAMETABLE
      • DROP
      • CHANGE
    • DUMPS
      • dump
      • dump prune
    • MAKE
    • MIGRATE
      • migrate
      • migrate fresh
    • ROLLBACK
  • Routing
    • with parameter
    • multiple parameters
    • with closure
    • group
    • controller grouping
  • Controllers
    • methods
  • Views
    • Passing Parameters
  • Validation
    • validate
      • validation type
  • Authentication
  • Alert Messages
  • Default Helpers
  • CSRF Protection
  • Email
  • Packages
    • Fortify
  • Themes and Templates
Powered by GitBook
On this page
  1. Database

Update

This is for the updating a row in the table. Where $form_data is array [ "table column" => "value" ]. The $whereParams is optional only.

// DB()->update($table, $form_data, $whereParams = '');

<?php

namespace App\Controllers;

class UserController
{
    public function update()
    {
        $form_data = [
            'email' => 'update@testmail.com',
            'fullname' => 'jagwarthegreat'
        ];

        DB()->update('users', $form_data);
    }
}

Take note that the email and fullname is the column name in your selected table which is users.

Always remember that the update method return a integer result, if the result is 1 it is true then 0 is false. False if the query produce an error and true if the query is successfully executed against the database.

PreviousInsertNextDelete

Last updated 2 years ago