src/Base.php
public static function makeUpdateSQL()
    {
        $tableName = self::getTableName();
        $setClause = "";
        $whereClause = "";
        $keysCount = count(self::$fields);
        $iterations = 1;

        foreach(self::$fields as $key => $val)
        {
            if($key == "id") {
                $whereClause = " WHERE id = ".$val;
            }
            else if($key != "result") {
                $setClause = $setClause.$key." = '".$val."'";

                if($keysCount > 2 && $iterations < $keysCount) {
                    $setClause = $setClause.", ";
                }
            }
            $iterations++;
        }

        $sql = "UPDATE ".$tableName." SET ".$setClause.$whereClause;

        return $sql;
    }
public static function makeUpdateSQL()
    {
        $tableName = self::getTableName();
        $setClause = "";
        $whereClause = "";
        $keysCount = count(self::$fields);
        $iterations = 1;

        foreach(self::$fields as $key => $val)
        {
            if($key == "id") {
                $whereClause = " WHERE id = ".$val;
            }
            else if($key != "result") {
                $setClause = $setClause.$key." = '".$val."'";

                if($keysCount > 2 && $iterations < $keysCount) {
                    $setClause = $setClause.", ";
                }
            }
            $iterations++;
        }

        $sql = "UPDATE ".$tableName." SET ".$setClause.$whereClause;

        return $sql;
    }
public static function makeUpdateSQL ( ) { $ tableName = self :: getTableName ( ) ; $ setClause = "" ; $ whereClause = "" ; $ keysCount = count ( self :: $ fields ) ; $ iterations = 1 ; foreach ( self :: $ fields as $ key => $ val ) { if ( $ key == "id" ) { $ whereClause = " WHERE id = " . $ val ; } else if ( $ key != "result" ) { $ setClause = $ setClause . $ key . " = '" . $ val . "'" ; if ( $ keysCount > 2 && $ iterations < $ keysCount ) { $ setClause = $ setClause . ", " ; } } $ iterations ++ ; } $ sql = "UPDATE " . $ tableName . " SET " . $ setClause . $ whereClause ; return $ sql ; }
This method generates the SQL statement used to update a record in the database
This method generates the SQL statement used to update a record in the database