Display in JSON format data from a database in SQL Server 2008 (AngularJS)

0

I need your help in the following please:

I am using AngularJS, I have a database in SQL SERVER 2008 are more than 5 thousand records that I have per table, what I want to do is bring all the information through JSON and show it, to be able to make search filters .. I already have my script, it just sends me an error in the query where it tells me the following:

  

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried   to allocate 47 bytes) in

I would like to ask for your advice to know if I am doing the right thing or I am recommended to use some other technology such as AJAX ... I leave you the script that I am using through AngularJS and PHP

function conexion(){
	$srv="Servidor"; 
		$opc=array("Database"=>"BD", "UID"=>"USR", "PWD"=>"PASS");
		$con=sqlsrv_connect($srv,$opc) or die(print_r(sqlsrv_errors(), true));
		return $con;
}
 
<?php
include ('conexion.php');
	$con = conexion();

	$sql="SELECT id_persona,nombre_completo,sexo, calle_no FROM PERSONAS ";
	$res=sqlsrv_query($con,$sql);

	$datos = array();

	while ($row = sqlsrv_fetch_array($res)) {
		$datos[] = $row;
	}

	echo json_encode($datos);

?> 
<!DOCTYPE html>
<html ng-app="datosApp">
    <head>
        <meta charset="utf-8"/>
        <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
        </script>
        <link rel="stylesheet" type="text/css" href=" css/style.css">

        <script>
        var misDatos = angular.module('datosApp', []);

        misDatos.controller("controladorDatos", function($scope, $http){

            $scope.importar = function(){
                //Se cambia succes por "THEN" y se le agrega .DATa al resultado
                $http.get('php/listas.php').then(function(datos){

                    $scope.equipo = datos.data;
                });
            }

            $scope.importar();
        });

//Agregar filtros
        misDatos.filter('cambiar', function(){
            var cambiarFiltro = function(valor){
                if (valor=='M') {
                    var nuevosDatos = "Masculino";
                }
                else{
                    var nuevosDatos = "Femenino";
                }
                return nuevosDatos;
            }
            return cambiarFiltro;
        });

        </script>
    </head>
    <body>
        <input ng-model="buscarFruta" type="text">
        <div ng-controller="controladorDatos">

            <table>
                <caption>Usuarios</caption>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Nombre</th>
                        <th>Usuario</th>
                        <th>Contraseña</th>
                        <th>Estado</th>
                    </tr>
                </thead>
                    <tr ng-repeat="usuario in equipo | filter:buscarFruta">
                        <td>{{usuario.id}}</td>
                        <td>{{usuario.nombre_completo}}</td>
                        <td>{{usuario.sexo | cambiar}}</td>
                        <td>{{usuario.id_persona}}</td>
                        <td>{{usuario.calle_no}}<td>
                    </tr>
            </table>

        </div>
    </body>
</html>

Thank you very much for your attention and I hope you have explained me!

    
asked by Checo 13.09.2017 в 19:16
source

0 answers