Symfony2:仅当复选框为真时,如何验证输入字段不为空?

2023-11-26

在 Symfony2 中,仅当复选框的值为 1(True)时,如何验证输入字段不是空白 - 否则允许空白?

更准确地说,我有一个带有复选框的表单和一个带有文本类型的输入字段。在 Symfony 的实体上应该有一个检查,当复选框的值为 True (1) / 选中时,输入的值不能为空。我在实体中使用注释。

任何建议将不胜感激。

更新/解决方案 - 基于 GeLo 的评论:

<?php

// src/ZeroSpace/Invoicing/Entity/Customer.php

namespace ZeroSpace\InvoicingBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="customers")
 * @UniqueEntity("billing_id")
 * @UniqueEntity("billing_name")
*/

class Customer {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="integer", length=6, unique=true)
     * @Assert\Length(min="6", max="6")
     */
    protected $billing_id;

    /**
     * @ORM\Column(type="string", length=100, unique=true)
     */
    protected $billing_name;

    /**
     * @ORM\Column(type="string", nullable=true, length=100)
     */
    protected $billing_consignee;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $billing_street;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $billing_address;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $billing_zip;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $billing_city;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $billing_country;

    /**
     * @ORM\Column(type="string", length=100)
     * @Assert\Email()
     */
    protected $billing_email;

    /**
     * @ORM\Column(type="boolean")
     */
    protected $billing_debit=false;

    /**
     * @ORM\Column(type="string", nullable=true, length=100)
     * @Assert\NotBlank(groups={"iban_required"})
     * @Assert\Iban(message = "This is not a valid International Bank Account Number (IBAN).")
     */
    protected $billing_iban;

    protected $locations;


/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set billing_id
 *
 * @param integer $billingId
 * @return Customer
 */
public function setBillingId($billingId)
{
    $this->billing_id = $billingId;

    return $this;
}

/**
 * Get billing_id
 *
 * @return integer 
 */
public function getBillingId()
{
    return $this->billing_id;
}

/**
 * Set billing_name
 *
 * @param string $billingName
 * @return Customer
 */
public function setBillingName($billingName)
{
    $this->billing_name = $billingName;

    return $this;
}

/**
 * Get billing_name
 *
 * @return string 
 */
public function getBillingName()
{
    return $this->billing_name;
}

/**
 * Set billing_consignee
 *
 * @param string $billingConsignee
 * @return Customer
 */
public function setBillingConsignee($billingConsignee)
{
    $this->billing_consignee = $billingConsignee;

    return $this;
}

/**
 * Get billing_consignee
 *
 * @return string 
 */
public function getBillingConsignee()
{
    return $this->billing_consignee;
}

/**
 * Set billing_street
 *
 * @param string $billingStreet
 * @return Customer
 */
public function setBillingStreet($billingStreet)
{
    $this->billing_street = $billingStreet;

    return $this;
}

/**
 * Get billing_street
 *
 * @return string 
 */
public function getBillingStreet()
{
    return $this->billing_street;
}

/**
 * Set billing_address
 *
 * @param string $billingAddress
 * @return Customer
 */
public function setBillingAddress($billingAddress)
{
    $this->billing_address = $billingAddress;

    return $this;
}

/**
 * Get billing_address
 *
 * @return string 
 */
public function getBillingAddress()
{
    return $this->billing_address;
}

/**
 * Set billing_zip
 *
 * @param string $billingZip
 * @return Customer
 */
public function setBillingZip($billingZip)
{
    $this->billing_zip = $billingZip;

    return $this;
}

/**
 * Get billing_zip
 *
 * @return string 
 */
public function getBillingZip()
{
    return $this->billing_zip;
}

/**
 * Set billing_city
 *
 * @param string $billingCity
 * @return Customer
 */
public function setBillingCity($billingCity)
{
    $this->billing_city = $billingCity;

    return $this;
}

/**
 * Get billing_city
 *
 * @return string 
 */
public function getBillingCity()
{
    return $this->billing_city;
}

/**
 * Set billing_country
 *
 * @param string $billingCountry
 * @return Customer
 */
public function setBillingCountry($billingCountry)
{
    $this->billing_country = $billingCountry;

    return $this;
}

/**
 * Get billing_country
 *
 * @return string 
 */
public function getBillingCountry()
{
    return $this->billing_country;
}

/**
 * Set billing_email
 *
 * @param string $billingEmail
 * @return Customer
 */
public function setBillingEmail($billingEmail)
{
    $this->billing_email = $billingEmail;

    return $this;
}

/**
 * Get billing_email
 *
 * @return string 
 */
public function getBillingEmail()
{
    return $this->billing_email;
}

/**
 * Set billing_debit
 *
 * @param boolean $billingDebit
 * @return Customer
 */
public function setBillingDebit($billingDebit)
{
    $this->billing_debit = $billingDebit;

    return $this;
}

/**
 * Get billing_debit
 *
 * @return boolean 
 */
public function getBillingDebit()
{
    return $this->billing_debit;
}

/**
 * Set billing_iban
 *
 * @param string $billingIban
 * @return Customer
 */
public function setBillingIban($billingIban)
{
    $this->billing_iban = $billingIban;
    return $this;
}

/**
 * Get billing_iban
 *
 * @return string 
 */
public function getBillingIban() {
    return $this->billing_iban;
}

}

    <?php
// src/Blogger/BlogBundle/Form/CustomerType.php

namespace ZeroSpace\InvoicingBundle\Form;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractType;

class CustomerType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {  
        $builder->add('billing_id');
        $builder->add('billing_name');
        $builder->add('billing_consignee');
        $builder->add('billing_street');
        $builder->add('billing_address');
        $builder->add('billing_zip');
        $builder->add('billing_city');
        $builder->add('billing_country');
        $builder->add('billing_email', 'email');
        $builder->add('billing_debit', 'checkbox');
        $builder->add('billing_iban');
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'ZeroSpace\InvoicingBundle\Entity\Customer',
            'validation_groups' => function(FormInterface $form) {
                $data = $form->getData();
                if($data->getBillingDebit() == 1) {
                    return array('Default', 'iban_required');
                }
                else {
                    return array('Default');
                }
            },
        ));
    }

    public function getName() {
        return 'customer';
    }
}


?>


<?php

namespace ZeroSpace\InvoicingBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use ZeroSpace\InvoicingBundle\Entity\Customer;
use ZeroSpace\InvoicingBundle\Form\CustomerType;

class CustomerController extends Controller {

    public function createAction(Request $request) {

        $form = $this->createForm(new CustomerType(), new Customer());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $data = $form->getData();
            $em = $this->getDoctrine()->getManager();
            $em->persist($data);
            $em->flush();

            return $this->redirect($this->generateUrl('customer_list'));
            // return $this->redirect($this->generateUrl('task_success'));
        }

        return $this->render('InvoicingBundle:Page:customers.html.twig', array(
            'form' => $form->createView()
        ));   
    }

    public function listAction() {
        $customers = $this->getDoctrine()->getManager()
            ->createQuery('SELECT c FROM InvoicingBundle:Customer c')
            ->execute();

        return $this->render(
            'InvoicingBundle:Customer:list.html.twig', 
            array('customers' => $customers));
    }

    public function showAction($id) {
        $customer = $this->get('doctrine')
            ->getManager()
            ->getRepository('InvoicingBundle:Customer')
            ->find($id);

        if (!$post) {
            // cause the 404 page not found to be displayed
            throw $this->createNotFoundException();
        }

        return $this->render(
            'InvoicingBundle:Page:customers.html.twig',
            array('customer' => $customer)
        );
    }

}

?>


我认为这是解决方案:

<?php

namespace ZeroSpace\InvoicingBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use ZeroSpace\InvoicingBundle\Entity\Customer;
use ZeroSpace\InvoicingBundle\Form\CustomerType;

class CustomerController extends Controller {

    public function createAction(Request $request) {

        $form = $this->createForm(new CustomerType(), new Customer());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $data = $form->getData();
            $em = $this->getDoctrine()->getManager();
            $em->persist($data);
            $em->flush();

            return $this->redirect($this->generateUrl('customer_list'));
            // return $this->redirect($this->generateUrl('task_success'));
        }

        return $this->render('InvoicingBundle:Page:customers.html.twig', array(
            'form' => $form->createView()
        ));   
    }

    public function listAction() {
        $customers = $this->getDoctrine()->getManager()
            ->createQuery('SELECT c FROM InvoicingBundle:Customer c')
            ->execute();

        return $this->render(
            'InvoicingBundle:Customer:list.html.twig', 
            array('customers' => $customers));
    }

    public function showAction($id) {
        $customer = $this->get('doctrine')
            ->getManager()
            ->getRepository('InvoicingBundle:Customer')
            ->find($id);

        if (!$post) {
            // cause the 404 page not found to be displayed
            throw $this->createNotFoundException();
        }

        return $this->render(
            'InvoicingBundle:Page:customers.html.twig',
            array('customer' => $customer)
        );
    }

}

?>

    <?php
// src/Blogger/BlogBundle/Form/CustomerType.php

namespace ZeroSpace\InvoicingBundle\Form;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractType;

class CustomerType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {  
        $builder->add('billing_id');
        $builder->add('billing_name');
        $builder->add('billing_consignee');
        $builder->add('billing_street');
        $builder->add('billing_address');
        $builder->add('billing_zip');
        $builder->add('billing_city');
        $builder->add('billing_country');
        $builder->add('billing_email', 'email');
        $builder->add('billing_debit', 'checkbox');
        $builder->add('billing_iban');
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'ZeroSpace\InvoicingBundle\Entity\Customer',
            'validation_groups' => function(FormInterface $form) {
                $data = $form->getData();
                if($data->getBillingDebit() == 1) {
                    return array('Default', 'iban_required');
                }
                else {
                    return array('Default');
                }
            },
        ));
    }

    public function getName() {
        return 'customer';
    }
}


?>

    <?php

    // src/ZeroSpace/Invoicing/Entity/Customer.php

    namespace ZeroSpace\InvoicingBundle\Entity;

    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
    use Symfony\Component\Validator\Constraints as Assert;

    /**
     * @ORM\Entity
     * @ORM\Table(name="customers")
     * @UniqueEntity("billing_id")
     * @UniqueEntity("billing_name")
    */

    class Customer {

        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;

        /**
         * @ORM\Column(type="integer", length=6, unique=true)
         * @Assert\Length(min="6", max="6")
         */
        protected $billing_id;

        /**
         * @ORM\Column(type="string", length=100, unique=true)
         */
        protected $billing_name;

        /**
         * @ORM\Column(type="string", nullable=true, length=100)
         */
        protected $billing_consignee;

        /**
         * @ORM\Column(type="string", length=100)
         */
        protected $billing_street;

        /**
         * @ORM\Column(type="string", length=100)
         */
        protected $billing_address;

        /**
         * @ORM\Column(type="string", length=100)
         */
        protected $billing_zip;

        /**
         * @ORM\Column(type="string", length=100)
         */
        protected $billing_city;

        /**
         * @ORM\Column(type="string", length=100)
         */
        protected $billing_country;

        /**
         * @ORM\Column(type="string", length=100)
         * @Assert\Email()
         */
        protected $billing_email;

        /**
         * @ORM\Column(type="boolean")
         */
        protected $billing_debit=false;

        /**
         * @ORM\Column(type="string", nullable=true, length=100)
         * @Assert\NotBlank(groups={"iban_required"})
         * @Assert\Iban(message = "This is not a valid International Bank Account Number (IBAN).")
         */
        protected $billing_iban;

        protected $locations;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set billing_id
     *
     * @param integer $billingId
     * @return Customer
     */
    public function setBillingId($billingId)
    {
        $this->billing_id = $billingId;

        return $this;
    }

    /**
     * Get billing_id
     *
     * @return integer 
     */
    public function getBillingId()
    {
        return $this->billing_id;
    }

    /**
     * Set billing_name
     *
     * @param string $billingName
     * @return Customer
     */
    public function setBillingName($billingName)
    {
        $this->billing_name = $billingName;

        return $this;
    }

    /**
     * Get billing_name
     *
     * @return string 
     */
    public function getBillingName()
    {
        return $this->billing_name;
    }

    /**
     * Set billing_consignee
     *
     * @param string $billingConsignee
     * @return Customer
     */
    public function setBillingConsignee($billingConsignee)
    {
        $this->billing_consignee = $billingConsignee;

        return $this;
    }

    /**
     * Get billing_consignee
     *
     * @return string 
     */
    public function getBillingConsignee()
    {
        return $this->billing_consignee;
    }

    /**
     * Set billing_street
     *
     * @param string $billingStreet
     * @return Customer
     */
    public function setBillingStreet($billingStreet)
    {
        $this->billing_street = $billingStreet;

        return $this;
    }

    /**
     * Get billing_street
     *
     * @return string 
     */
    public function getBillingStreet()
    {
        return $this->billing_street;
    }

    /**
     * Set billing_address
     *
     * @param string $billingAddress
     * @return Customer
     */
    public function setBillingAddress($billingAddress)
    {
        $this->billing_address = $billingAddress;

        return $this;
    }

    /**
     * Get billing_address
     *
     * @return string 
     */
    public function getBillingAddress()
    {
        return $this->billing_address;
    }

    /**
     * Set billing_zip
     *
     * @param string $billingZip
     * @return Customer
     */
    public function setBillingZip($billingZip)
    {
        $this->billing_zip = $billingZip;

        return $this;
    }

    /**
     * Get billing_zip
     *
     * @return string 
     */
    public function getBillingZip()
    {
        return $this->billing_zip;
    }

    /**
     * Set billing_city
     *
     * @param string $billingCity
     * @return Customer
     */
    public function setBillingCity($billingCity)
    {
        $this->billing_city = $billingCity;

        return $this;
    }

    /**
     * Get billing_city
     *
     * @return string 
     */
    public function getBillingCity()
    {
        return $this->billing_city;
    }

    /**
     * Set billing_country
     *
     * @param string $billingCountry
     * @return Customer
     */
    public function setBillingCountry($billingCountry)
    {
        $this->billing_country = $billingCountry;

        return $this;
    }

    /**
     * Get billing_country
     *
     * @return string 
     */
    public function getBillingCountry()
    {
        return $this->billing_country;
    }

    /**
     * Set billing_email
     *
     * @param string $billingEmail
     * @return Customer
     */
    public function setBillingEmail($billingEmail)
    {
        $this->billing_email = $billingEmail;

        return $this;
    }

    /**
     * Get billing_email
     *
     * @return string 
     */
    public function getBillingEmail()
    {
        return $this->billing_email;
    }

    /**
     * Set billing_debit
     *
     * @param boolean $billingDebit
     * @return Customer
     */
    public function setBillingDebit($billingDebit)
    {
        $this->billing_debit = $billingDebit;

        return $this;
    }

    /**
     * Get billing_debit
     *
     * @return boolean 
     */
    public function getBillingDebit()
    {
        return $this->billing_debit;
    }

    /**
     * Set billing_iban
     *
     * @param string $billingIban
     * @return Customer
     */
    public function setBillingIban($billingIban)
    {
        $this->billing_iban = $billingIban;
        return $this;
    }

    /**
     * Get billing_iban
     *
     * @return string 
     */
    public function getBillingIban() {
        return $this->billing_iban;
    }

}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Symfony2:仅当复选框为真时,如何验证输入字段不为空? 的相关文章

  • Fluent 验证和库

    前几天在寻找完全不同的东西时 我偶然发现了两个用于在 NET 中进行流畅验证的库 这个概念似乎很有趣 因为到目前为止我正在使用通常的条件和分支语句 if else case 等 进行验证 特别是 它使得链接某些条件相对容易 这些条件在某些情
  • Api平台所需的过滤器

    我正在使用 API 平台 并且我已经定义了一个自定义过滤器 如下所示https api platform com docs core filters creating custom filters https api platform co
  • 使用 Doctrine NestedSet 进行面包屑导航

    我有一个实现 NestedSet 行为的模型 Page actAs NestedSet hasManyRoots true rootColumnName root id columns slug string 255 name string
  • aws eb deploy 不加载环境变量

    我正在通过 eb deploy 将 symfony 项目部署到 ec2 实例 aws linux 2 部署后迁移脚本运行良好 但当我尝试使用 ec2 user 运行 symfony 命令时 出现有关数据库凭据错误的错误 这是因为我推送了带有
  • Rails 验证日期范围的唯一性

    我有一个涉及员工缺勤记录的应用程序 我需要确保每条记录的开始日期和结束日期不重叠 例如 如果我输入了从今天开始到明天结束的缺勤记录 则不可能以任何方式在该日期范围内输入另一个缺勤记录 所以我不能制作一个从前天开始 然后在后天或任何更晚的日期
  • 如何使用自定义 ValidationAttribute 来确保两个属性匹配?

    我们使用 xVal 和标准DataAnnotationsValidationRunner描述here http blog stevensanderson com 2009 01 10 xval a validation framework
  • 使用 jQuery 检查输入是否为空

    我有一个表单 我希望填写所有字段 如果单击某个字段然后未填写 我想显示红色背景 这是我的代码 apply form input blur function if input text is empty this parents p addC
  • Symfony2 Twig 扩展

    我在实现树枝扩展时遇到一些问题 我需要创建自己的过滤器 子过滤器 所以我想到了使用twig扩展 我在 MyApp Bundle WebsiteBundle 和文件上创建了一个名为 Extension 的文件夹 网站扩展 php namesp
  • 在 Symfony 序列化中更改序列化属性名称

    我正在使用 Symfony 序列化器 效果很好 use Symfony Component Serializer Annotation Groups Groups default notification public function g
  • 如何正确清理来自 AngularJS 控制器的无效输入的表单?

    我有一个 AngularJS 表单 其中包含 除其他字段之外 类型之一url 后者很重要 因为这会强制相应的输入成为有效的 URL 在某些条件下 例如 要关闭具有此类表单的模式对话框 我想以编程方式清除该表单 为此 我实现了方法reset基
  • 角度 2 通道数组到自定义验证器(模板驱动形式)

    我需要将一个对象数组传递给 a2 自定义验证器 然后我想根据该数组中的记录验证模板驱动表单字段的值 但是我无法检索验证器内的对象 我唯一能看到的是它的名称作为字符串 如有任何帮助 我们将不胜感激
  • 确定 C 字符串是否是 C 中的有效 int

    我需要检查 C 字符串是否是有效整数 我都尝试过 int num atoi str and int res sscanf str d num 但发送字符串 8 9 10 这两行都仅返回 8 而没有指示该字符串的无效性 谁能提出替代方案 看看
  • 如何从实体内部获取Web目录路径?

    我研究了如何用 Doctrine 处理文件上传 http symfony com doc current cookbook doctrine file uploads html我不想硬编码 DIR web this gt getUpload
  • 使用 Symfony 4 命令加载不同的 .env 文件

    env运行 Symfony 4 命令时会解析文件 如果 dotenv 可用 这在开发时工作正常 而且 我想测试我的代码 所以另一个环境 因此我需要加载另一个 env file 我喜欢 Docker 运行容器的方式 docker run e
  • Symfony2 Secure by IP 不起作用

    在我的 Symfony 2 3 1 Security YML 中 我有这一行 安全 yml access control path mysecurearea roles IS AUTHENTICATED ANONYMOUSLY ip 0 0
  • 当数据验证失败时保留表单字段中的值

    我在弄清楚验证失败时如何保留用户数据时遇到问题 我对 PHP 有点陌生 所以我的逻辑可能会犯一些巨大的错误 目前 如果验证失败 所有字段都会被清除 并且 Post 数据也会消失 这是一些代码 假设用户输入无效电子邮件 我希望保留 名称 字段
  • 如何在原则 2 迁移中删除外键

    我想在原则 2 迁移中删除外键 但没有 dropForeignKeyConstraint 有谁知道怎么丢掉吗 public function down Schema schema table schema gt getTable table
  • 学说迁移后备

    我们正在使用原则迁移 当迁移包含多个操作并且其中一个操作失败时 通常会出现问题 例如 如果迁移添加了 5 个外键 其中第 5 个失败 而字段长度不同 则修复字段错误并重新生成迁移不会not修复整个问题 而现在出现一个与 4 个密钥已存在有关
  • Doctrine EntityManager 清除嵌套实体中的方法

    我想用学说批量插入处理 http doctrine orm readthedocs org en latest reference batch processing html为了优化大量实体的插入 问题出在 Clear 方法上 它表示此方法
  • Symfony 4:添加 Twig_Extension_StringLoader

    在我的 Symfony 4 项目中 我有一个包含 HTML 的变量 我尝试使用 Twig 显示该变量 我想使用template from string 功能但我必须添加Twig Extension StringLoader到 Twig 环境

随机推荐

  • 为什么我需要 PHP 中的 isset() 函数?

    我试图理解这之间的区别 if isset POST Submit do something and if POST Submit do something 在我看来 如果 POST Submit 变量为 true 则它被设置 在这种情况下为
  • 使用类型名称将 JSON 文本反序列化为特定对象类型 [重复]

    这个问题在这里已经有答案了 我曾经使用下面的代码将 JSON 文本反序列化为强类型对象 Trainer myTrainer JsonConvert DeserializeObject
  • 如何在 Swift 中将字符串编码/解码为 Base64?

    我想将字符串转换为 Base64 我在几个地方找到了答案 但它在 Swift 中不再起作用 我使用的是 Xcode 6 2 我相信答案可能适用于以前的 Xcode 版本 而不适用于 Xcode 6 2 有人可以指导我在 Xcode 6 2
  • 从包含文件返回

    在 PHP 中 如何从包含的脚本返回到包含它的脚本 IE 1 主脚本 2 应用 3 包括 基本上 我想从 3 返回到 2 return 不起作用 2 应用程序中的代码 page User Manager if permission 13 1
  • TZupdater 因 tzdata2016g 版本失败

    TZUpdater 2 1 0 在 tzdata2016g 版本中失败 对于 Java 8 它会失败并显示 源目录不包含文件 VERSION 错误 而对于 Java 7 它会以 JRE 更新到版本 tzdataunknown 注释完成 其原
  • Firebase 可扩展性限制

    This post表示当单个节点开始拥有 1 10 百万个子节点时 FireBase 将遇到问题 如果应用程序中的用户超过 1000 万 应该如何处理 在所有示例中 我认为用户只是单个节点 用户 的子节点 Firebase 不适合处理长列表
  • 在 Emacs 上同时运行 Clojure 和其他 Lisp

    I use Aquamacs 并且 Aquamacs 预先配备了SLIME setq inferior lisp program usr local bin sbcl add to list load path Library Applic
  • 有没有可用于印度语言的词干分析器[关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 目前不接受答案 是否有任何针对印度语言的词干分析器的实现 例如 印地语 泰卢固语 可用 印地语分析器 带有词干分析器 可在 Lucene 中使用 正是基于此算法 p
  • string1 >= string2 未在 Linq to SQL 中实现,有解决方法吗?

    如何在 Linq to SQL 中执行 string1 gt string2 如果您正在寻找 gt 通常会写成 gt 那么你不能直接用字符串来做到这一点 您可以通过以下方式获得相同的行为相比于 string1 CompareTo strin
  • 这是角度模板缓存清除的好方法吗?

    我正在尝试在我的角度应用程序上实现一些缓存清除 其方式仍然允许缓存 但在我们将新代码推送到生产环境时会破坏它 到目前为止 我的设置涉及使用 grunt 缓存破坏器https www npmjs org package grunt cache
  • 转到 HTML 中另一个页面的 div

    我想从不同的页面转到特定页面的 DIV 那可能吗 I tried a href file html product Hello a 但它只是去file html home thanks C 我的 file html 中有 但它不断被重定向到
  • Microchip PIC 的 Modbus 堆栈

    有人可以建议为 Microchip PIC18 处理器实现 Modbus RTU 从站的开源实现吗 我正在寻找 RS 232 RS 485 的 Modbus RTU 实现 但 Modbus TCP IP 实现也将受到欢迎 我已经为 PIC1
  • 如何在 IPython 笔记本中打开交互式 matplotlib 窗口?

    我正在使用 IPython pylab inline有时想要快速切换到交互式 可缩放的 matplotlib GUI 来查看绘图 当您在终端 Python 控制台中绘制某些内容时会弹出 我怎么能这么做呢 最好不要离开或重新启动我的笔记本 I
  • Android - 如何通过用户名以编程方式切换用户?

    我是 Android 新手 我必须在工作中创建一个执行以下任务的应用程序 我监听一个应该向我发送用户名的套接字 收到用户名后 我需要在平板电脑上切换到该用户帐户 如果我收到与当前活动用户相同的用户名 我不需要切换 显然 我们的平板电脑已获得
  • unaccent() 阻止 Postgres 中的索引使用

    我想从导入到 PostgreSQL 9 3 5 的 OpenStreetMap 数据库中检索给定名称的路线 操作系统是 Win7 64 位 为了具有一定的容错能力 我使用了 Postgres 的非重音扩展 我的查询如下所示 SELECT F
  • 使用补丁(Flask)进行单元测试行为

    我在尝试着patch我的 Flask api 中的方法 但似乎方法调用没有被替换 做app test client 做一些我所缺少的事情 例如 如果我跑 patch k stats mstats def test ps self mstat
  • 如果“设置”->“显示”->“显示尺寸”更改为“大”或“小”,则禁用应用程序或活动缩放

    在我的应用程序中 我不想允许它调整大小 因为它会产生设计问题 我尝试过android resizeableActivity false 在应用程序标签和启动器活动标签中 但它没有帮助 我已经找到了解决方案 如果系统文本大小更改或显示大小设置
  • socket.io 握手返回错误“传输未知”

    我正在尝试使用大象io将事件从我的 PHP 脚本发送到我的 Nodejs 服务器 使用这个库进行测试时 我注意到握手没有按预期发生 After 阅读有关客户端 服务器握手的规范使用socket io 我测试了对我的nodejs服务器的简单握
  • 春豆到底是什么?

    我还没有找到我能理解的 Spring bean 的高级定义 我在 Grails 文档和书籍中经常看到它们被引用 但我认为了解它们是什么会很有帮助 那么什么是Spring bean呢 如何使用它们 它们与依赖注入有什么关系吗 Spring核心
  • Symfony2:仅当复选框为真时,如何验证输入字段不为空?

    在 Symfony2 中 仅当复选框的值为 1 True 时 如何验证输入字段不是空白 否则允许空白 更准确地说 我有一个带有复选框的表单和一个带有文本类型的输入字段 在 Symfony 的实体上应该有一个检查 当复选框的值为 True 1