Skip to content

Instantly share code, notes, and snippets.

View sorbing's full-sized avatar

Stanislav Butsenko sorbing

View GitHub Profile
@sorbing
sorbing / gist:2936367
Created June 15, 2012 12:59
sape-module-joomla
<?php
/**
* @package Sape
* @subpackage Base
* @author JExtension {@link http://jextension.net}
* @author Created on 14-Jan-2011
* @license GNU/GPL
*/
//-- No direct access
defined('_JEXEC') or die('Restricted access');
@sorbing
sorbing / db_dump_subquery_in_left_join.sql
Created July 10, 2012 18:40
DB Dump. Subquery in LEFT JOIN ON...
CREATE TABLE IF NOT EXISTS `stats` (
`user_id` int(10) unsigned NOT NULL,
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
`type` varchar(10) NOT NULL,
PRIMARY KEY (`date`,`type`,`user_id`),
KEY `fk_user_id_1` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `stats` (`user_id`, `date`, `type`) VALUES
(1, '2012-06-30 21:00:00', 'тип №1'),
class Cars
{
function createCar($brand)
{
$car_obj = 0;
switch ($brand) {
case 'toyota': $car_obj = new Toyota;
case 'bmw': $car_obj = new Bmw;
default: $car_obj = new Toyota;
}
### Structure
CREATE TABLE IF NOT EXISTS `tube`.`film` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;
...
public function formAction(Request $request, $id)
{
$task = new Task();
if ($request->getMethod() == 'GET')
{
$task->setTask('Новая задача');
$task->setDueDate(new \DateTime('tomorrow'));
<?php
namespace App\CommonBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
{
{% block content %}
{% if subscribe %}
<p>{{ 'newsletter.title.subscribe_success'|trans }}</p>
{% else %}
<p>{{ 'newsletter.title.unsubscribe_success'|trans }}</p>
{% endif %}
<script type="text/javascript">
window.addEvent('domready', function()
{
location.href = '{{ back_url }}';
window.routes['url_cities'] = {{ path('stepcart_city_list') }}; // сейвим текущий роут
var w = new CcWidget({
widgets: [
{% for i in range(0, form.user.addresses|length-1) %}
{
...
}{% if not loop.last %},{% endif %}
{% endfor %}
],
/*
---
name: Router
description: StepCart router manager
license: MIT.
copyright: Copyright (c) 2011
requires: []
provides: [Router]
public function addTag(Tag $tag)
{
if ($this->collTags === null) {
$this->initTags();
}
if (!$this->collTags->contains($tag))
{
// ~~~
if ($tag->getId()) {
$tag = TagQuery::create()->findOneById($tag->getId());