标签: zend-framework

形式不渲染

我正在使用zend框架,并尝试使用zend表单,MVC和OOP输出一个简单的登录表单.

我的代码如下:Controller IndexController.php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $this->view->loginForm = $this->getLoginForm(); 
    }

    public function getLoginForm()
    {
        $form = new Application_Form_Login;
        return $form;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是以下形式:Login.php

class Application_Form_Login extends Zend_Form
{

    public function init()
    {
        $form = new Zend_Form;

        $username = new Zend_Form_Element_Text('username');
        $username
            ->setLabel('Username')
            ->setRequired(true)
        ;

        $password = new Zend_Form_Element_Password('password');
        $password
            ->setLabel('Password')
            ->setRequired(true)
        ;

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Login');

        $form->addElements(array($username, $password, $submit));

    }
}
Run Code Online (Sandbox Code Playgroud)

并且视图:index.phtml …

php oop model-view-controller zend-framework zend-form

0
推荐指数
1
解决办法
95
查看次数

如何在没有.htaccess的情况下设置zend框架网站

我的.htaccess的设置

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Run Code Online (Sandbox Code Playgroud)

伙计们,我需要你的专业知识.建议或想法会很棒.我想要发生的是,我将删除我的.htaccess文件并创建一个index.php来配置所有内容......是否可能?

你能举个例子吗?先感谢您.

php .htaccess zend-framework

0
推荐指数
1
解决办法
633
查看次数

在将值添加到db之前将值转义是否是一个好习惯?

我有一个Zend项目,经过一段时间的研究,我发现了这个想法.当然这与安全性有关,目的是避免xss攻击.

其他解决方案是在显示它们之前逃避它们,但这将包括许多特殊情况,并且有一些时间因为Zend没有实现这样的任何东西.

这些是在回复它们之前逃避的解决方案 http://codeutopia.net/blog/2007/11/10/how-to-automatically-escape-template-variables-in-zend_view/https:/ /github.com/chikaram/gnix-view

这些有点太老了,也许有人已经遇到了这个问题,并且已经提供了更好的解决方案,Zend提供的新功能我还没有找到.

那么,在将值添加到数据库之前转义值以及在我希望在我的值中使用javascript代码时为罕见的特殊情况制作排除数组是一个好的做法吗?

如果您有更好的解决方案,将非常感谢链接和示例.

security zend-framework escaping

0
推荐指数
1
解决办法
85
查看次数

致命错误:达到最大功能嵌套级别'100',正在中止!使用ionCube装载机

我收到致命错误:达到了'100'的最大功能嵌套级别,正在中止!与ionCube loader.And我不想卸载IonCube.So我该怎么办?

php zend-framework magento ioncube

0
推荐指数
1
解决办法
9262
查看次数

理解PHP短标签

我在这个视频中看到了这个,但我不明白它是如何<?=工作的.
有人能帮我吗?

php zend-framework

0
推荐指数
1
解决办法
113
查看次数

从zend框架中的url获取路由名称

我需要在zend框架中从url获取路由名称.
我想将URL作为参数传递给将返回URL的路由名称的方法.

使用Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()我可以得到当前的路线名称.

php zend-framework

0
推荐指数
1
解决办法
5974
查看次数

尝试运行doctrine命令时"em未定义错误"

我刚刚设置了一个ZF2项目并为Doctrine2配置了所有项目而没有问题.它工作,现在只是给我一个错误,因为它找不到我想要查询的数据库表.

实体也正确设置,全部按照http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/

所以想使用CLI来创建表等,但是在运行任何CLI命令时我都会得到

[InvalidArgumentException]       
The helper "em" is not defined.
Run Code Online (Sandbox Code Playgroud)

我正在使用的命令

php doctrine.php orm:schema-tool:update --dump-sql
Run Code Online (Sandbox Code Playgroud)

我从文件夹运行doctrine.php

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/bin
Run Code Online (Sandbox Code Playgroud)

现在,如果我将CLI用于我的一个ZF1.11项目,它可以正常工作.

为了实现这一点,我必须编辑位于其下的cli-config.php文件

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/doctrine/orm/tools
Run Code Online (Sandbox Code Playgroud)

该文件的内容是:

<?php

require_once '../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../../lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ …
Run Code Online (Sandbox Code Playgroud)

configuration zend-framework command-line-interface doctrine-orm

0
推荐指数
1
解决办法
3142
查看次数

当我在zend框架中使用toArray()时出现致命错误

我需要帮助来消除toArray()zend框架中的致命错误.

致命错误:在非对象上调用成员函数toArray()

我在我的控制器中使用以下代码

$obj     = new Admin_Model_UserMapper();
$where   = array('id = ?'=>$decryptId);
$data    = $obj->fetchAll($where);
//  $currentData = $data->current();
$dataArr = $data->toArray();


$form = new Admin_Form_UserForm();
$form->setAction('edit-user');
$form->populate($dataArr);
Run Code Online (Sandbox Code Playgroud)

当我使用toArray()或时,我在两种情况下都会出现致命错误current().

我已经使用了以下代码,但没有得到任何解决方案,它产生相同的错误:

$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()->from('user')->where('id= ?',$decryptId);
$stmt = $select->query();
$result = $stmt->fetchAll();
if(count($result) > 0){
    $dataArr = $result->toArray();
} 
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

zend-framework toarray

0
推荐指数
1
解决办法
3327
查看次数

使用Zend Gdata电子表格获取工作表ID

我正在尝试使用zend gdata来获取电子表格的工作表.我可以使用工作表列表

$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($key);
$feed = $spreadSheetService->getWorksheetFeed($query);
Run Code Online (Sandbox Code Playgroud)

我想知道如何获得worksheetId.

我感谢任何帮助.

php zend-framework gdata zend-gdata

0
推荐指数
1
解决办法
1702
查看次数

在zend框架中使用where where获取数组

如何获取catid ="someid"的数组?

我试过这个,但没有奏效

public function findCatArr($catid)
{
    $select = $this->getDbTable()->select();
    $select->setIntegrityCheck(false);
    $select->from('photo',array('id','catid','pic','desc'
    ))->where("catid"." LIKE '%".$catid."%'");
    $row = $this->getDbTable()->fetchAll($select);


    if (0 == count($row)) {
        return;
    }else{

        return $row->toArray();


        }   
    }
Run Code Online (Sandbox Code Playgroud)

zend-framework

0
推荐指数
1
解决办法
166
查看次数