Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Aug 232010
 

Set the auto increment start value in MySQL?

Answer:

In MySQL, you can change the table's auto increment start value by the following command.

mysql> ALTER TABLE `my_table` AUTO_INCREMENT = 2000;

Query OK, 2 rows affected (0.06 sec)
Records: 2  Duplicates: 0  Warnings: 0
Aug 222010
 

Convert array to object in PHP

Answer:

It is easy to cast an object to an array in PHP, using the following method.

<?php

    $obj = new stdClass(); 
    $obj->foo = "foo";
    $obj->bar = "bar";

    var_dump ( (array) $obj );

It will print out...

array(2) {
  ["foo"]=>
  string(3) "foo"
  ["bar"]=>
  string(3) "bar"
}
Aug 212010
 

A simple hash in Perl

Answer:

Hash is a dictionary like data structure in Perl. It allows you to direct access to a particular element inside a hash.

Example:

use strict;
use warnings;

my %hash = (
        "a" => "1",
        "b" => "2",
);

print $hash{"b"}; # print "2"