getSingleScalarResult example

/** * {@inheritdoc} */
    public function createPaymentInstance($orderId$userId$paymentId)
    {
        $orderAmount = Shopware()->Models()->createQueryBuilder()
            ->select('orders.invoiceAmount')
            ->from(Order::class, 'orders')
            ->where('orders.id = ?1')
            ->setParameter(1, $orderId)
            ->getQuery()
            ->getSingleScalarResult();

        $addressData = Shopware()->Models()->getRepository(Customer::class)
            ->find($userId)->getDefaultBillingAddress();

        $debitData = $this->getCurrentPaymentDataAsArray($userId);
        if (!\is_array($debitData)) {
            $debitData = [];
        }

        $date = new DateTime();
        $data = [
            
'lastName' => $data['lastname'],
                'orderNumber' => $orderNumber,
            ],
        ]);

        $customerEmail = (string) Shopware()->Models()->createQueryBuilder()
            ->select('customer.email')
            ->from(Customer::class, 'customer')
            ->where('customer.id = ?1')
            ->setParameter(1, $userId)
            ->getQuery()
            ->getSingleScalarResult();

        $mail->addTo($customerEmail);

        Shopware()->Template()->assign('data', [
            'orderNumber' => $orderNumber,
            'accountHolder' => $data['account_holder'],
            'address' => $data['address'],
            'city' => $data['city'],
            'zipCode' => $data['zipcode'],
            'bankName' => $data['bank_name'],
            'iban' => $data['iban'],
            
/** * @param int $id * * @return int */
    public function getChildrenCountList($id)
    {
        $builder = $this->getCategoriesByParentBuilder($id);
        $builder->select('COUNT(categories) as categoriesCount');

        return (int) $builder->getQuery()->getSingleScalarResult();
    }

    /** * @param int $id * * @return array */
    public function getFullChildrenList($id)
    {
        return $this->getCategoriesByParentBuilder($id)->getQuery()->getArrayResult();
    }

    
/** * @deprecated in 5.6, will be private in 5.8 * * Return number of free serials for given esdId * * @param int $esdId * * @return int */
    public function getFreeSerialCount($esdId)
    {
        return (int) $this->getRepository()->getFreeSerialsCountByEsdQuery($esdId)->getSingleScalarResult();
    }

    /** * Event listener function of the product backend module. * Creates new serial numbers */
    public function saveSerialsAction()
    {
        $esdId = $this->Request()->getParam('esdId');

        $esd = $this->get('models')->getRepository(Esd::class)->find($esdId);

        
/** * {@inheritdoc} */
    public function createPaymentInstance($orderId$userId$paymentId)
    {
        $orderAmount = Shopware()->Models()->createQueryBuilder()
            ->select('orders.invoiceAmount')
            ->from(Order::class, 'orders')
            ->where('orders.id = ?1')
            ->setParameter(1, $orderId)
            ->getQuery()
            ->getSingleScalarResult();

        $addressData = Shopware()->Models()->getRepository(Customer::class)
            ->find($userId)->getDefaultBillingAddress();

        $date = new DateTime();
        $data = [
            'payment_mean_id' => $paymentId,
            'order_id' => $orderId,
            'user_id' => $userId,
            'firstname' => $addressData->getFirstname(),
            'lastname' => $addressData->getLastname(),
            
foreach ($blogCategories as $blogCategory) {
            $blogCategoryIds[] = $blogCategory['id'];
        }

        // Count total number of associated blog articles         $builder = Shopware()->Models()->getRepository(Blog::class)->getListQueryBuilder(
            $blogCategoryIds,
            []
        );
        $numResults = $builder->select('COUNT(blog)')
            ->getQuery()
            ->getSingleScalarResult();

        return (int) $numResults;
    }

    /** * Count the number of articles which need an update * * @param int $shopId * * @return string */
    
->select('COUNT(preset)')
            ->from(Preset::class, 'preset')
            ->where('preset.name = :name');

        if ($preset->getId()) {
            $qb->andWhere('preset.id != :id')
                ->setParameter('id', $preset->getId());
        }

        $result = $qb->setParameter('name', $preset->getName())
            ->getQuery()
            ->getSingleScalarResult();

        if ($result > 0) {
            throw new CustomValidationException(sprintf('Preset with name %s already exists', $preset->getName()));
        }
    }

    /** * @param bool $fetchAll * * @return array[] */
    
Home | Imprint | This part of the site doesn't use cookies.