<?php trait Singleton { # Holds Parent Instance private static $_instance; # Holds Reference To zVal protected $_args; # Create The Instance protected function __construct() {} # Static Call To Get Instance public static function getInstance() { return self::$_instance ?? (self::$_instance = new self()); } # Bind zVal Of Passed Reference To Index protected function _bindParam(&$val) { $this->_arg = &$val; return $this; } } abstract class Model { abstract public function save(); # Set your DB up here } class MyModel extends Model { use \Singleton { _bindParam as public bindParam; } public function save() { print_r($this->_arg); } } MyModel::getInstance()->bindParam($row); foreach([['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']] as $key => $row) { $row[0] = 'Changed'; MyModel::getInstance()->save(); }
You have javascript disabled. You will not be able to edit any code.