@param \PDOStatement $stmt
@param $model

@return EntityObjectStorage
331768
public function executeQuery($model, \PDOStatement $stmt)
    {
        $objectStorage = new EntityObjectStorage();
        if ($stmt->execute()) {
            if ($stmt->rowCount() > 1) {
                return $this->getList($model, $stmt);
            }
            $objectStorage->attach($this->hydrate($model, $stmt->fetchObject()));

        } else {
            $this->log(ILog::T_ERROR, implode(',', $stmt->errorInfo()));
        }

        return $objectStorage;
    }
1247220
private function bind($stmt) {

		$meta 	= $stmt -> result_metadata();
		$double = [];
		$vars 	= [];

		if($stmt -> field_count > 0) {

			while($field = $meta -> fetch_field()) {

				$columnname  = $field -> name;
				${$columnname} = null;
				
				if(true === array_key_exists($columnname, $vars)) {
					$double[] = $columnname;
				}
				else {
					$vars[$columnname] = &${$columnname};
				}
			}
		}

		if(count($double) > 0) {
			return trigger_error(sprintf('Column %s in field list is ambiguous', implode(', ', array_unique($double))));
		}

		call_user_func_array([$stmt, 'bind_result'], $vars);

		return $vars;
	}
475045
public function setModel(Model $model)
    {
        $this->model = $model;

        $this->query->from($model->getTable());

        return $this;
    }
1006192
public function findByParam($modelName, $param)
    {
        /**
         * @var ModelStorageDecorator $storedModel
         */
        foreach ($this->storage as $key => $storedModel) {
            if ($modelName != get_class($storedModel)) {
                continue;
            }

            if ($this->containsParam($storedModel, $param)) {
                return $storedModel->getModel();
            }
        }

        return null;
    }
124725
private function executeParallel($stmt, array $values = null): PromiseInterface
    {
        if (is_string($stmt)) {
            $stmt = $this->emulatePrepare((string) $stmt, $values);
        } else {
            if (!$stmt instanceof Statement) {
                throw new \InvalidArgumentException(sprintf('Expected %s object, got %s', Statement::class, get_class($stmt)));
            }
            if (!$stmt instanceof EmulatedStatement) {
                $stmt = $this->emulatePrepare((string) $stmt, $values ?? $stmt->getValues());
            } elseif (null !== $values) {
                $stmt = $stmt->withValues($values);
            }
        }
        try {
            // Clone connection (Mysqli Asynchronous queries require a different connection to work properly)
            $credentials = $this->getCredentials();
            $cnx         = self::createLink($credentials);
            if ($this->hasOption('charset')) {
                $cnx->set_charset($this->getOption('charset'));
            }
        } catch (mysqli_sql_exception $e) {
            throw new AccessDeniedException($e->getMessage(), (int) $e->getCode(), $e);
        }

        $stmt->bind();
        $promise = MysqliAsync::query($stmt->getRunnableQuery(), $cnx)->then(function ($result) use ($cnx, $stmt) {
            if (!$result instanceof mysqli_result) {
                $result = null;
            }
            return new Result($cnx, $result);
        });

        return $promise;
    }
1136921
public static function find($stmt)
    {
         try {
            $result = $stmt->fetch(PDO::FETCH_ASSOC);
            if(! $result) {
                throw new Exception(" Record not found.");
            }

            $object = new static;
            $object->id = $result['id'];
            $object->result = json_encode($result);

            return $object;
        }
        catch(PDOException $pe) {
            return $pe->getMessage();
        }
        catch(Exception $e) {
            return $e->getMessage();
        }
    }
666932
private function doCommitDelete(Model $model)
    {
        $this->dispatchLifecycleEvent(Events::preDelete, $model);

        $this->getPersisterFor($model->getType())->delete($model);
        $model->getState()->setDeleted();

        $this->dispatchLifecycleEvent(Events::postDelete, $model);
        return $model;
    }
1294128
public function hydrateAll($stmt, $resultSetMapping, array $hints = array())
    {
        $this->_stmt  = $stmt;
        $this->_rsm   = $resultSetMapping;
        $this->_hints = $hints;

        $this->prepare();

        $result = $this->hydrateAllData();

        $this->cleanup();

        return $result;
    }
1282288
protected function ensureCanDefine(Stmt $stmt, $scopeType = self::CLASS_TYPE)
    {
        $name = $this->getFullyQualifiedName($stmt->name);

        // check for name collisions
        $errorType = null;
        if ($this->classExists($name)) {
            $errorType = self::CLASS_TYPE;
        } elseif ($this->interfaceExists($name)) {
            $errorType = self::INTERFACE_TYPE;
        } elseif ($this->traitExists($name)) {
            $errorType = self::TRAIT_TYPE;
        }

        if ($errorType !== null) {
            throw $this->createError(\sprintf('%s named %s already exists', \ucfirst($errorType), $name), $stmt);
        }

        // Store creation for the rest of this code snippet so we can find local
        // issue too
        $this->currentScope[\strtolower($name)] = $scopeType;
    }
1147111
protected function _process( $stmt )
	{
		$msg = 'Changing code from "product" to "default" in "mshop_product_type"';
		$this->_msg($msg, 0);

		if ($this->_schema->tableExists('mshop_product_type') )
		{
			$result = $this->_conn->create( $stmt )->execute();
			$cntRows = $result->affectedRows();
			$result->finish();

			if ( $cntRows ) {
				$this->_status( sprintf( 'migrated (%1$d)', $cntRows ) );
			} else {
				$this->_status( 'OK' );
			}
		}
		else
		{
			$this->_status('OK');
		}
	}
1345434
public function save(Model $model)
    {
        if ($this->fieldId) {
            $model->setAttribute($this->fieldKey, $this->fieldId);
        }

        return parent::save($model);
    }
960888
public function execute(array $params, $stmt = null)
    {
        try {
            if (!is_null($stmt)) {
                $this->stmt = $stmt->execute($params);
            } else {
                if (!$this->stmt) {
                    throw new \Exception("Prepared stetement not found.");
                }
                $this->stmt->execute($params);
            }
            return $this;
        } catch (\PDOException $e) {
            die("Error: " . $e->getMessage());
        } catch (\Exception $e) {
            die("Error: " . $e->getMessage());
        }
    }
703652
protected function saveEntity(\stdClass $postParams, ModelInterface $entity, $isCreating) {
        $postParams = $this->findPostParams($postParams, $entity);
        /** @var Save $save */
        $save = $this->getDI()->get(Save::class, [$this->request, $entity, $isCreating]);
        return $save->process($postParams);
    }
1338617
public static function createFromModel(Model $model)
    {
        $table = $model->getTable();

        $dc = new static($table);

        $dc->strTable = $model->getTable();
        $dc->activeRecord = $model;
        $dc->intId = $model->id;

        return $dc;
    }
813362
public function execBound(\PDOStatement $stmt, array $values)
    {
        $ord = 1;
        foreach ($values as $val) {

            if (is_bool($val)) {

                $stmt->bindValue($ord, $val, \PDO::PARAM_BOOL);

            } elseif (is_resource($val)) {

                $stmt->bindValue($ord, $val, \PDO::PARAM_LOB);

            } elseif ((string)$val === ((string)(int)$val)) {

                $stmt->bindValue($ord, $val, \PDO::PARAM_INT);

            } else {

                $stmt->bindValue($ord, $val, \PDO::PARAM_STR);
            }
            $ord++;
        }

        return $stmt->execute();
    }
1372911
public function get(AbstractModel $model, $param = null)
    {
        $this->modelStorage->rewind();

        foreach ($this->modelStorage as $storedModel) {
            if ($storedModel === $model) {
                return $model;
            }
        }

        return null;
    }
357920
private function executeStatement($stmt) {

		if(true !== $stmt -> execute()) {

			if($this -> getLastErrno() > 0) {
				return trigger_error(sprintf('A database error occured with error number "%s" and message: "%s"', $this -> getLastErrno(), $this -> getLastError()), E_USER_ERROR);
			}

			return false;
		}

		$stmt -> store_result();

		return $stmt;
	}