Resetting the auto increment number with SQL (MySQL)

Posted on Tuesday 19 January 2010

When you have a table with 10 records and an auto increment field ID and you delete the tenth record e.g.The next time you insert a record, the ID will be 11 and not 10. You can reset the auto increment number by using this SQL:

ALTER TABLE table_name AUTO_INCREMENT=10

This will reset the next auto increment value to current largest value in the auto increment column + 1. That way the auto increment will start with 10 instead of 11.

Read more →

Auto expand columns Finder‘s column view

Posted on Tuesday 19 January 2010

Finder normally doesn‘t remember the width when you double click the column width button. This can be frustrating when you‘re filenames are usually pretty long. There‘s a solution to this. Just press the option key(alt) and drag to the desired width. This expands all the columns to the same size and remembers the width for the next time you open up your Finder window.

Auto expland column Finder

Read more →

MySQL replace function - Find and replace values in database with sql

Posted on Tuesday 12 January 2010

A great piece of sql that can save you a lot of time. The replace sql function finds and replaces values in a database.

Just fill in the table_name, table_field, the value your searching for and with which value you want to replace it with.

UPDATE table_name SET table_field = REPLACE(table_field, 'value', 'new_value') WHERE my_field LIKE '%value%';

Read more →

Remove the index.php from your codeigniter URL

Posted on Sunday 19 July 2009

Codeigniter logo

When you create a standard new codeigniter application, there’s always a index.php in your url. It’s kind of ugly in your url so I prefer to remove this. To remove this you need to do a couple of things:

change the $config[‘index_page’] to $config[‘index_page’]=”“ instead of $config[‘index_page’]=“index.php”

Next create a .htaccess file in the root of your CI application with the following:

RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond % !-f
RewriteCond % !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Read more →

Automatic config Base_url in CodeIgniter

Posted on Friday 17 July 2009

If you don‘t like to change the base_url in your Codeigniter config file every time you move your application. Just replace it with the following:

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

It also works with https.

Read more →

How to resize youtube or vimeo movies with PHP

Posted on Wednesday 27 May 2009

Vimeo Youtube

You have to use the preg_replace php function here. The $video variable holds the embed code fromyoutube, vimeo or other similar website that use these parameters in their embed codes in the example. You can change the width and height in the second parameter. This will replace the width and height parameters in you embed code with you desired width. That way inserted video‘s by users won‘t mess up your layout.

$video = preg_replace('/(width)=("[^"]*")/i', 'width="270"', $video);
$video = preg_replace('/(height)=("[^"]*")/i', 'height="270"', $video);

Read more →