Skip to content

Instantly share code, notes, and snippets.

do not pull or push

Torsten Brieskorn bitkorn

do not pull or push
View GitHub Profile
bitkorn / js_stringToUpperFirst.js
Created Aug 5, 2017
make the first character to upper letter
View js_stringToUpperFirst.js
function stringToUpperFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
bitkorn / ZF2_log-SQL-string-with-driver-support.php
Created Jul 23, 2017
ZF2 log SQL string with driver-support
View ZF2_log-SQL-string-with-driver-support.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;
bitkorn / zf2_short_fetch_all_tablex.php
Last active Feb 24, 2017
Short way to fetch all from SQL database with ZF2 \Zend\Db\Adapter\Adapter (no ZF2 \Zend\Db\TableGateway\AbstractTableGateway).
View zf2_short_fetch_all_tablex.php
namespace Foo;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\ParameterContainer;
class A
View zf2_table_lastInsertValue.php
* @param array $data
* @return int
public function insertSomeAndGetLastInsertValue(array $data)
$insert = $this->sql->insert();
View zf2_base-url_in_controller_and_view.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
class A
* @var \SomeNamespace\SomeMember
private $someMember;
bitkorn / shop_article_join_with_count.sql
Created Nov 4, 2016
SELECT tables and JOIN over other and COUNT some table rows
View shop_article_join_with_count.sql
-- without DISTINCT comes false results
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,
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
class Module implements Zend\ModuleManager\Feature\ViewHelperProviderInterface
public function getViewHelperConfig()
return array(
'factories' => [
'simpleAnchor' => function(\Zend\View\HelperPluginManager $hpm) {
$sm = $hpm->getServiceLocator();
bitkorn / mysql_enum_values.sql
Last active Oct 29, 2016
get possible ENUM values from a MySQL table column
View mysql_enum_values.sql
-- @return(raw) ('firstenumvalue','secondenumvalue','...')
-- cut the word 'enum'
TABLE_SCHEMA = 'schemaname'
AND TABLE_NAME = 'tablename'
AND COLUMN_NAME = 'columnname';
bitkorn / db.local.php
Last active Oct 27, 2016
ZF2 multiple database conf
View db.local.php
* first DBConfig
$dbParamsGlobal = array(
'hostname' => 'localhost',
'database' => 'somedbname',
'username' => 'root',
'password' => 'secretpasswd',
You can’t perform that action at this time.