Skip to content

Commit

Permalink
FEAT: update_as method for update column to column in a table
Browse files Browse the repository at this point in the history
  • Loading branch information
drosanda committed Nov 19, 2020
1 parent 77ade1e commit 7ffa776
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
52 changes: 52 additions & 0 deletions kero/sine/SENE_MySQLi_Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,13 @@ public function insert($table,$datas=array(),$multi_array=0,$is_debug=0){
return $res;
}
}
/**
* Update current table with key value array
* key and value are automatically escaped
* @param string $table table name
* @param array $datas key value pair
* @return object this object
*/
public function update($table,$datas=array(),$debug=0){
if(!is_array($datas)){
trigger_error('Must be array!');
Expand Down Expand Up @@ -1190,6 +1197,51 @@ public function update($table,$datas=array(),$debug=0){
$this->flushQuery();
return $res;
}
/**
* Same as update, but with no chararcter escape. Useful for update from column to column in single table.
* *$this->db->esc() may required
* @param string $table table name
* @param array $datas key value pair
* @return object this object
*/
public function update_as($table,$datas=array(),$is_debug=0){
if(!is_array($datas)){
trigger_error("Must be array!");
die();
}

$sql = "UPDATE `".$table."` SET ";

foreach($datas as $key=>$val){
if($val=="now()" || $val=="NOW()" || $val=="NULL" || $val=="null"){
$sql .="".$key."=".$val.",";
}else{
$sql .="".$key."=".($val).",";
}
}

$sql = rtrim($sql,",");

if(!empty($this->in_where)){
$this->in_where = rtrim($this->in_where,"AND ");
$this->in_where = rtrim($this->in_where,"OR ");
$sql .= " WHERE ".$this->in_where;
}

if(!empty($this->pagesize) && ($this->tis_limit>0)){
$b = $this->pagesize;
$sql .= " LIMIT ".$b;
}

$this->query_last = $sql;
if($is_debug){
http_response_code(500);
die($sql);
}
$res = $this->exec($sql);
$this->flushQuery();
return $res;
}
public function delete($table,$is_debug=0){
if(empty($table)){
trigger_error("Missing table name while deleting");
Expand Down
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Seme Framework v3.1.3
# Seme Framework v3.1.4
[![Build Status](https://travis-ci.org/drosanda/seme-framework-v3.svg?branch=3.1.0)](https://travis-ci.org/drosanda/seme-framework-v3) [![Coverage Status](https://coveralls.io/repos/github/drosanda/seme-framework/badge.svg?branch=3.1.0)](https://coveralls.io/github/drosanda/seme-framework?branch=3.1.0) [![Website seme.framwork.web.id](https://img.shields.io/website-up-down-green-red/http/seme.framework.web.id)](https://seme.framework.web.id/)

Seme Framework PHP MVC Framework for creating small and medium app that needed for fast delivery. At first version of Seme Framework used for building API (Middle Ware) for another Application such as android, iOS, etc. And now as increasing of requirement, Seme Framework has expand the limit for creating Small and Medium App.
Expand All @@ -15,6 +15,11 @@ This framework suitable for Programmer that only know about Manual way of code.
- Admin Friendly. Seme Framework has re-routing feature for admin page, without refactoring the MVC.
- Theme Engine. Seme Framework has feature who can PUSH the content inside the layout view. Also support theming engine, if you want change the Style, you just clone the original one and modified safely.

## Version 3.1.4
This is latest version of 3.1 branch. Here is the new feature:
- add SENE_MySQLi_Engine::update_as method
- Fix SENEROOT base directory defining method for docker support

## Version 3.1.3
This is latest version of 3.1 branch. Here is the new feature:
- add join_as method
Expand Down

0 comments on commit 7ffa776

Please sign in to comment.