@@ -396,7 +396,7 @@ public function truncate(string $table, int $flags = 0) {
396
396
return $ this ->query ($ query , $ flags , "truncate " );
397
397
}
398
398
399
- public function insert (string $ table , array $ values , int $ flags = 0 ) {
399
+ public function insert (string $ table , array $ values , int $ flags = 0 , string $ name = " insert " ) {
400
400
$ cols = ["" ];
401
401
$ useCols = true ;
402
402
foreach ($ values as $ k => $ v ) {
@@ -430,19 +430,19 @@ public function insert(string $table, array $values, int $flags = 0) {
430
430
};
431
431
$ r = $ this ->query ("
432
432
INSERT INTO {$ table }{$ colString } VALUES ( {$ valueString })
433
- " , $ flags , " insert " );
433
+ " , $ flags , $ name );
434
434
return (boolval ($ flags & self ::INSERT_RETURN_ID ) ? $ this ->connect ->lastInsertId () : $ r );
435
435
}
436
436
437
- public function delete (string $ table , $ cond , int $ flags = 128 ) {
437
+ public function delete (string $ table , $ cond , int $ flags = 128 , string $ name = " delete " ) {
438
438
$ all = !boolval ($ flags & self ::COND_OR );
439
439
$ condString = $ this ->getCondString ($ cond , $ all );
440
440
return $ this ->query ("
441
441
DELETE FROM ` {$ table }` WHERE {$ condString }
442
- " , $ flags , " delete " );
442
+ " , $ flags , $ name );
443
443
}
444
444
445
- public function update (string $ table , $ cond , ar
10046
ray $ values , int $ flags = 128 ) {
445
+ public function update (string $ table , $ cond , array $ values , int $ flags = 128 , string $ name = " update " ) {
446
446
$ all = !boolval ($ flags & self ::COND_OR );
447
447
$ condString = $ this ->getCondString ($ cond , $ all );
448
448
$ string = "" ;
@@ -461,7 +461,7 @@ public function update(string $table, $cond, array $values, int $flags = 128) {
461
461
};
462
462
return $ this ->query ("
463
463
UPDATE ` {$ table }` SET {$ string } WHERE {$ condString }
464
- " , $ flags , " update " );
464
+ " , $ flags , $ name );
465
465
}
466
466
467
467
public function add (string $ table , string $ name , string $ type , int $ length , bool $ null , string $ where , string $ key , string $ data = "" , int $ flags = 0 ) {
@@ -639,6 +639,18 @@ public function get(string $table, $options = [], int $flags = 4096) {
639
639
$ result = $ this ->selectJoinWhere ($ table , $ join , $ on , $ cond , $ order , $ cols , $ limit , $ flags | $ jointype | $ condtype | $ ordertype , "get " );
640
640
return $ this ->fetch ($ flags | $ fetch );
641
641
}
642
+
643
+ public function put (string $ table , $ data , $ cond = NULL , int $ flags = 0 ) {
644
+ if (is_int ($ cond ) && $ flags ==0 ) {
645
+ $ flags = $ cond ;
646
+ $ cond = NULL ;
647
+ };
648
+ if (empty ($ cond ))
649
+ return $ this ->insert ($ table , $ data , $ flags , "put " );
650
+ if ($ data ===NULL )
651
+ return $ this ->delete ($ table , $ cond , $ flags , "put " );
652
+ return $ this ->update ($ table , $ cond , $ data , $ flags , "put " );
653
+ }
642
654
643
655
public function cond ($ cond = "" ) {
644
656
return new SSQLCond ($ this , $ cond );
0 commit comments