@@ -39,9 +39,14 @@ OUTLINE
39
39
- [ Database Connection] ( #database-connection )
40
40
- [ Usage] ( #usage )
41
41
- [ find()] ( #find )
42
- - [ insert()] ( #insert )
42
+ - [ findOne()] ( #findone )
43
+ - [ findAll()] ( #findall )
44
+ - [ insert()] ( #insert ) )
45
+ - [ batchInsert()] ( #batchinsert )
43
46
- [ update()] ( #update )
47
+ - [ replace()] ( #replace )
44
48
- [ delete()] ( #delete )
49
+ - [ getLastInsertID()] ( #getlastinsertid ) )
45
50
- [ Soft Deleted] ( #soft-deleted )
46
51
- [ Configuration] ( #configuration-1 )
47
52
- [ Usage] ( #usage-1 )
@@ -52,6 +57,8 @@ OUTLINE
52
57
- [ Configuration] ( #configuration-3 )
53
58
- [ Load Balancing for Databases] ( #load-balancing-for-databases )
54
59
- [ Pessimistic Locking] ( #pessimistic-locking )
60
+ - [ Helpers] ( #helpers )
61
+ - [ indexBy()] ( #indexby )
55
62
56
63
---
57
64
@@ -390,6 +397,14 @@ $result = $this->Model->delete();
390
397
$this->Model->delete(123, true);
391
398
```
392
399
400
+ ### getLastInsertID()
401
+
402
+ Get the insert ID number when performing database inserts.
403
+
404
+ ``` php
405
+ $result = $this->Model->insert(['name' => 'Nick Tsai']);
406
+ $lastInsertID = $this->Model->getLastInsertID();
407
+ ```
393
408
394
409
---
395
410
@@ -643,3 +658,30 @@ $this->Model->find()->where('id', 123)
643
658
$result = $this->Model->lockForUpdate()->row_array();
644
659
$this->Model->getDB()->trans_complete();
645
660
```
661
+
662
+ ---
663
+
664
+ HELPERS
665
+ -------
666
+
667
+ ### ` indexBy() `
668
+
669
+ Index by Key
670
+
671
+ ``` php
672
+ array indexBy(Array & $array [, Integer $key] [, Boolean $obj2Array])
673
+ ```
674
+
675
+ Example:
676
+
677
+ ``` php
678
+ $records = $this->Model->findAll();
679
+ $this->Model->indexBy($records, 'sn');
680
+
681
+ // Result example of $records:
682
+ [
683
+ 7 => ['sn'=>7, title=>'Foo'],
684
+ 13 => ['sn'=>13, title=>'Bar']
685
+ ]
686
+ ```
687
+
0 commit comments