Skip to content

Instantly share code, notes, and snippets.

<?php
$query = DB::select('user_comments.comment')->from('users')
->join('user_comments')
->on('users.id', 'user_comments.user_id')
->where('users.username', 'shadowhand');
-- Triggers an error:
-- You can't specify target table "users" for update in FROM clause
DELETE FROM users WHERE id IN (SELECT id FROM users)
-- Note that this is a poor example, a better example would be adding a JOIN
-- or a HAVING or some other kind of complex filter. Keepin' it simple!
<?php
$query = DB::insert('users', array('username', 'password'));
for ($i = 0, $max = 20; $i < $max; $i++)
{
$query->values(array(uniqid(), sha1(text::random(6))));
}
echo Kohana::debug((string) $query, $query->execute());
Hi, my name is Ma. Reina S. (29826). How may I help you? [12:26:30 PM]
Woody Gilk: Hello [12:26:40 PM]
Woody Gilk: I have a Linksys WET54G and i am trying to upgrade the firmware [12:26:51 PM]
Ma. Reina S. (29826): Hello, Woody! [12:27:31 PM]
Ma. Reina S. (29826): Before we proceed, may I ask which country you are located? [12:27:32 PM]
Woody Gilk: USA [12:27:07 PM]
Ma. Reina S. (29826): Please look underneath the device itself and get the Version number and the Serial Number (SN) of the WET54G. I need to verify that. [12:28:02 PM]
Woody Gilk: no version number [12:27:50 PM]
Woody Gilk: serial number is bdy003802478 [12:28:11 PM]
Ma. Reina S. (29826): Okay, it's version 1. Please hold on. [12:29:00 PM]
<?php
$query = DB::select(array('COUNT("*")', 'count'))
->from('user_comments')
->join('users')
->on('users.id', '=', 'user_comments.user_id')
->where('users.username', '=', 'shadowhand');
<?php
// Check if routes are cached
if ( ! Route::cache())
{
Route::set('admin', 'admin(/<action>(/<id>))')
->defaults(array(
'controller' => 'admin'
));
<?php
$watermark = Image::factory(DOCROOT.'upload/kohana.png')
->resize(200, 200);
$this->request->set_header('content-type', 'image/jpeg');
$this->request->response = Image::factory(DOCROOT.'upload/andyou.jpg')
->resize(800, 600)
->crop(500, 500)
->watermark($watermark, -1, -1, 80)
<?php
// Create the reflection image
$reflection = $this->_create($this->width, $this->height + $height);
// Copy the image to the reflection
imagecopy($reflection, $this->_image, 0, 0, 0, 0, $this->width, $this->height);
// Do alpha blending on the background
imagealphablending($reflection, TRUE);
<?php
function reflection($height, $opacity)
{
// Convert an opacity range of 0-100 to 0-127
$opacity = round(($opacity * 127 / 100) - 127);
// Set the opacity step, based on the height
$stepping = (127 - $opacity) / $this->height;
@shadowhand
shadowhand / reflection.php
Created July 15, 2009 20:20
Adding reflections to images using GD
<?php
protected function _do_reflection($height, $opacity)
{
// Convert an opacity range of 0-100 to 127-0
$opacity = round(abs(($opacity * 127 / 100) - 127));
if ($opacity < 126)
{
// Calculate the opacity stepping