Zend Framework con SQL SERVER

30 views
Skip to first unread message

Guillermo Rodriguez

unread,
Aug 26, 2013, 12:37:08 PM8/26/13
to comuni...@googlegroups.com
Saludos amigos soy nuevo en Zend y hecho cosas basicas todo con MySQL pero en este proyecto tiene que ser si o si con SQL SERVER ya configure mi wampserver para conectarme a SQL SERVER con al Driver [PHP_SQLSRV]
extension=php_pdo_sqlsrv_53_ts_vc6.dll
y se la prueba con 

<?php  
   $c = new PDO( "sqlsrv:Server=INFORMATICA09\SQL2005 ; Database = BD_DESA ", "sa", "xxxxx", array(PDO::SQLSRV_ATTR_DIRECT_QUERY => true)); 

   $query = ' select * from dbo.TbLocal'; 
   $stmt = $c->query( $query ); 
   while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ) { 
       var_dump($row ) ; 
   }
   $c = null; 
 
?>

y me muestra los datos de la tabla TbLocal ahoro kise hacer la conexion con SQL a Zend de la siguiente manerar en el ini

resources.db.adapter = "pdo_mssql"
resources.db.params.host = "INFORMATICA09\SQL2005"
resources.db.params.username = "sa"
resources.db.params.password = "guillermo"
resources.db.params.dbname = "bd_visitas"



y configure un logeo simple y este es el codigo
---------------------------------------------------------------------------------------------

    public function indexAction()
    {         
        $form = new Application_Form_Login();   
        if($this->_request->isPost()){
            $params = $this->_getAllParams();
            if($form->isValid($params)){
                $values = $form->getValues();
                // Condigurando el Zend_Auth_Adapter_DbTable 
                $db = Zend_Db_Table::getDefaultAdapter();
                $authAdapter = new Zend_Auth_Adapter_DbTable($db);
                $authAdapter->setTableName('usuario1');
                $authAdapter->setIdentityColumn('login');
                $authAdapter->setCredentialColumn('pwd');
                $authAdapter->setCredentialTreatment('MD5(?)');
                $authAdapter->setIdentity($values['login']);
                $authAdapter->setCredential($values['pwd']);
                $auth = Zend_Auth::getInstance();
                $result = $auth->authenticate($authAdapter);
                if($result->isValid()){
                    $authStg = $auth->getStorage();
                    $authStg->write($authAdapter->getResultRowObject(null, 'pwd'));
                    //$this->_redirect($this->url);
                    $this->_redirect('/registro/listar');
                } else {
                    echo "Usuario o Password Incorrecto !!";                    
                }              
            }            
        }
        $this->view->form = $form;
    }

------------------------------------------------------------------------------------------------

rurounize

unread,
Aug 26, 2013, 1:00:23 PM8/26/13
to comuni...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages