@@ -481,7 +481,7 @@ public function exists($statement, array $bindings = [])
481481 }
482482
483483 /********************************************************************************
484- * fetch data methods
484+ * fetch affected methods
485485 *******************************************************************************/
486486
487487 /**
@@ -513,7 +513,6 @@ public function fetchAssoc($statement, array $bindings = [])
513513 public function fetchOne ($ statement , array $ bindings = [])
514514 {
515515 $ sth = $ this ->execute ($ statement , $ bindings );
516-
517516 $ result = $ sth ->fetch (PDO ::FETCH_ASSOC );
518517
519518 $ this ->freeResource ($ sth );
@@ -531,7 +530,6 @@ public function fetchColumn($statement, array $bindings = [])
531530 public function fetchValue ($ statement , array $ bindings = [])
532531 {
533532 $ sth = $ this ->execute ($ statement , $ bindings );
534-
535533 $ result = $ sth ->fetchColumn ();
536534
537535 $ this ->freeResource ($ sth );
@@ -567,7 +565,6 @@ public function fetchObject($statement, array $bindings = [], $class = 'stdClass
567565 public function fetchAll ($ statement , array $ bindings = [])
568566 {
569567 $ sth = $ this ->execute ($ statement , $ bindings );
570-
571568 $ result = $ sth ->fetchAll (PDO ::FETCH_ASSOC );
572569
573570 $ this ->freeResource ($ sth );
@@ -598,7 +595,6 @@ public function fetchAssocs($statement, array $bindings = [])
598595 public function fetchColumns ($ statement , array $ bindings = [])
599596 {
600597 $ sth = $ this ->execute ($ statement , $ bindings );
601-
602598 $ column = $ sth ->fetchAll (PDO ::FETCH_COLUMN , 0 );
603599
604600 $ this ->freeResource ($ sth );
@@ -612,8 +608,8 @@ public function fetchColumns($statement, array $bindings = [])
612608 public function fetchGroups ($ statement , array $ bindings = [], $ style = PDO ::FETCH_COLUMN )
613609 {
614610 $ sth = $ this ->execute ($ statement , $ bindings );
615-
616611 $ group = $ sth ->fetchAll (PDO ::FETCH_GROUP | $ style );
612+
617613 $ this ->freeResource ($ sth );
618614
619615 return $ group ;
@@ -637,6 +633,32 @@ public function fetchObjects($statement, array $bindings = [], $class = 'stdClas
637633 return $ result ;
638634 }
639635
636+ /**
637+ * 每行调用一次函数
638+ *
639+ * @param string $statement
640+ * @param array $bindings
641+ * @param callable $func
642+ *
643+ * ```php
644+ * function ($col1, $col2) {
645+ * return $col1 . $col2;
646+ * }
647+ * ```
648+ *
649+ * @return void
650+ */
651+ public function fetchFuns ($ statement , array $ bindings = [], callable $ func )
652+ {
653+ $ sth = $ this ->execute ($ statement , $ bindings );
654+
655+ $ result = $ sth ->fetchAll (PDO ::FETCH_KEY_PAIR );
656+
657+ $ this ->freeResource ($ sth );
658+
659+ return $ result ;
660+ }
661+
640662 /**
641663 * {@inheritdoc}
642664 */
0 commit comments