Skip to content

Instantly share code, notes, and snippets.

@OrlandoST
Last active April 4, 2018 17:20
Show Gist options
  • Save OrlandoST/a8e7cb83cfc333101a25425dd9c0e6a0 to your computer and use it in GitHub Desktop.
Save OrlandoST/a8e7cb83cfc333101a25425dd9c0e6a0 to your computer and use it in GitHub Desktop.
ZF2_Snippets
<?php
/***************************************************
* View Helper
**************************************************/
$this->getRequest()->getPost('id', null);
$this->headScript()->appendFile('/static/js/parsley.js','text/javascript');
$this->headLink()->appendStylesheet('/static/css/themenuebersicht.css');
// get snippet path
$this->snippet("xyz")->getSnippet()->getFullPath()
// set layout in view
$this->layout()->setLayout("standard");
// set content in layout
$this->layout()->content
Object_Service::createFolderByPath($parentpath);
/***************************************************
* Get config
**************************************************/
$config = Api::_()->sm()->get('Config');
/***************************************************
* Zend Paging
**************************************************/
$page = $this->_getParam("page");
$per_page = 5;
$paginator = Zend_Paginator::factory($events);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(5);
$paginator->setItemCountPerPage($per_page);
$this->view->paginator = $paginator;
$this->view->available_pages = ceil(count($events) / $per_page);
$this->view->per_page = $per_page;
$this->view->page = $page;
$this->view->query_string = Website_Controller_Action::getQueryString();
/***************************************************
* Zend Select
**************************************************/
$select = $db->select()
->from(array('p' => 'products'),
array('product_id',
'cost_plus_tax' =>
new Zend_Db_Expr('p.cost * 1.08'))
);
//Select with joins
$select = $this->getSelect()
->join(array('t2' => $t2Name), "t2.product_id=$t1Name.$primaryKey", array('amount', 'dealerprice', 'enduserprice'), 'left')
;
$select->where(array("$t1Name.$primaryKey" => $id));
$rowset = $this->selectWith($select);
return $rowset->current();
/***************************************************
* Get SQL string
**************************************************/
use Zend\Db\Sql\Sql;
$sql = new Sql($this->adapter);
var_dump($sql->buildSqlString($select));
delete from cheese_discount WHERE product_id in (
SELECT product_id FROM cheese_2_category
WHERE category_id=20
)
$adapter = new Zend\Db\Adapter\Adapter([
'driver' => 'Pdo_Mysql',
'hostname' => 'db.radiushost.net',
'database' => 'orlandost_sana',
'username' => 'orlandost_sana',
'password' => '111',
]);
$result = $adapter->query('INSERT INTO `application_settings` (name, value) VALUES ("varer", "types")', Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment