Skip to content

Instantly share code, notes, and snippets.

@indrekots
indrekots / resque.php
Created October 21, 2013 08:23
Enqueueing a job with Resque and PHP
<?php
Resque::enqueue("default", 'application\models\jobs\TestJob', array("arg1" => "myArg1");
@indrekots
indrekots / Job.php
Last active December 25, 2015 21:09
Interface for job classes when using php-resque
<?php
/**
* Defines a php-resque job
*/
interface Job
{
/**
* Executes the job
@indrekots
indrekots / HelloJob.php
Last active December 25, 2015 21:09
Sample job class using php-resque
<?php
class HelloJob implements Job
{
public function perform()
{
echo "Hello world";
}
}
@indrekots
indrekots / ChildModel.php
Created October 11, 2013 09:50
Defining a "belongs to" relation with Yii's namespaced Active Record
<?php
...
public function relations() {
return array(
'ParentModel' => array(self::BELONGS_TO, 'application\models\ParentModel', 'parent_model_id')
);
}
...
@indrekots
indrekots / ParentModel.php
Created October 11, 2013 09:48
Defining a "has many" relation with Yii's namespaced Active Record
<?php
...
public function relations() {
return array(
'childModels' => array(self::HAS_MANY, 'application\models\ChildModel', 'parent_model_id')
);
}
...
@indrekots
indrekots / ParentModel.php
Created October 11, 2013 09:34
Defining a "has many" relation with Yii's Active Record
<?php
...
public function relations() {
return array(
'childModels' => array(self::HAS_MANY, 'ChildModel', 'parent_model_id')
);
}
...
@indrekots
indrekots / ChildModel.php
Created October 11, 2013 09:27
Defining a "belongs to" relation using Yii's Active Record
<?php
...
public function relations() {
return array(
'parentModel' => array(self::BELONGS_TO, 'ParentModel', 'parent_model_id')
);
}
...
@indrekots
indrekots / error.txt
Created October 11, 2013 09:09
Cannot redeclare class error with PHP
PHP Fatal error: Cannot redeclare class application\models\ChildModel in /var/www/demo/app/models/ChildModel.php on line 49
@indrekots
indrekots / cronjob
Created October 8, 2013 13:27
Example cron job
*/2 * * * * php /home/user/Desktop/hw.php >> /home/user/Desktop/hw.log
@indrekots
indrekots / crontab.sh
Created October 8, 2013 13:26
Open crontab editor
crontab -e