How to execute a Stored Procedure Oracle with ZF2

I was some problems to execute an oracle stored procedure in ZF2 with out params.

The following is an example, how finally I implemented the solution.

Procedure


CREATE OR REPLACE procedure sp_tmp(rtn out char) AS
begin

rtn := '1';

end sp_tmp;
/

 Call from ZF2 Model


        $adapter = $this->tableGateway->adapter;
        $statement = $adapter->createStatement();
        $statement->prepare("begin sp_tmp(:output); end;");

        $parameterContainer = new \Zend\Db\Adapter\ParameterContainer;
        //Uncomment this if you want to add IN params
        //$parameterContainer->offsetSet('inParam', '', $parameterContainer::TYPE_STRING); 
        $parameterContainer->offsetSetReference('output', 'output'); // Out parameter
        $statement->setParameterContainer($parameterContainer);
        $statement->execute();

        var_dump($parameterContainer->getNamedArray());

 Finally I got this:

array (size=1)
  'output' => &string '1' (length=1)
Anuncios

Compartir variables en Controladores con AngularJS

Para compartir variables en controladores con AngularJS:

 App.js

MiWeb.factory('Data', function () {
    return { Nombre: '' };
});

MiWeb.controller('IndexCtrl', function ($scope, Data) {
    $scope.Data = Data;
});

MiWeb.controller('PanelCtrl', function ($scope, Data) {
    $scope.Data = Data;
});

Index.html

<div ng-controller="IndexCtrl">
    <input type="text" ng-model="Data.Nombre">
    <br>Mi nombre es : <strong>{{Data.Nombre}}</strong>
</div>

<hr>

<div ng-controller="PanelCtrl">
    El nombre ingresado en el controlador index es: {{Data.Nombre}}
</div>