View zf2_controller-with-viewHelper.php
<?php
namespace MyApp\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use \Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
class IndexController extends AbstractActionController
{
View php_baseurl.php
<?php
$baseUrl = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))) . '://' . $_SERVER['SERVER_NAME'];
View js_stringToUpperFirst.js
function stringToUpperFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
View ZF2_log-SQL-string-with-driver-support.php
<?php
namespace BitkornShop\Table\Basket;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\HydratingResultSet;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Adapter\AdapterAwareInterface;
/**
View zf2_short_fetch_all_tablex.php
<?php
namespace Foo;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\ParameterContainer;
class A
{
View zf2_table_lastInsertValue.php
<?php
/**
*
* @param array $data
* @return int
*/
public function insertSomeAndGetLastInsertValue(array $data)
{
$insert = $this->sql->insert();
$insert->values($data);
View zf2_base-url_in_controller_and_view.php
<?php
$uri = $this->getRequest()->getUri();
$base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
// or
$serverUrlHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('ServerUrl');
$url = $serverUrlHelper($this->url()->fromRoute('some_routename'));
// or in view
echo $this->serverUrl($this->url('some_routename'))
View call_invoke_method_of_a_class_member.php
<?php
class A
{
/**
*
* @var \SomeNamespace\SomeMember
*/
private $someMember;
View shop_article_join_with_count.sql
-- without DISTINCT comes false results
SELECT
sa.*,
sac.*,
COUNT(DISTINCT sagr.shop_article_group_relation_id) AS count_group_relation,
COUNT(DISTINCT sai.shop_article_image_id) AS count_image,
COUNT(DISTINCT sar.shop_article_relation_id) AS count_relation,
sasd.*,
COUNT(DISTINCT sasi.shop_article_size_item_id) AS count_size_item,
COUNT(DISTINCT sacomm.shop_article_comment_id) AS count_comment
View Module-PHP-getViewHelperConfig_ViewHelper-with-URL-ViewHelper.php
<?php
public function getViewHelperConfig()
{
return array(
'factories' => [
'simpleAnchor' => function(\Zend\View\HelperPluginManager $hpm) {
$sm = $hpm->getServiceLocator();
$helper = new View\Helper\W3\SimpleAnchor();
$vhm = $sm->get('viewhelpermanager');
$helper->setUrlHelper($vhm->get('url'));