12/30/06

I am 68% Masculine

according to a quiz, i am 32% feminine and 68% masculine:
You Are 32% Feminine, 68% Masculine

You are in touch with your masculine side.
You are not overly sensitive and not easily moved.
Occasionally, though, something will get through and touch your heart!

PHP vs. X programming language

soruce: zend.com by: kschroeder

Being a new Zender I’ve spent some time in the recent past looking at people’s opinions about PHP now that it directly affects the work I do. In my research I have found a lot of interesting “opinions” about PHP vs. this that and the other thing, usually in the form of lists. “4 reasons why Java will outlast PHP”, for example.

So, I figured I’d come up with a list of responses to the naysayers concerning PHP.

1) PHP lacks several important features
PHP is specifically web-centric. This means that many of the features that programmers from general purpose programming languages complain about PHP not having are simply not that important in a web based environment. Asynchronous execution using threads, for example, has very little use when a browser makes one request at a time.

2) PHP doesn’t have “real” object oriented programming support.
Knocking PHP because of a lack of OOP support is so “2003”. While the initial implementation of OOP in PHP 4 was not so great, PHP 5 implemented OOP in a manner that brings it very much in line with the other OOP programming languages out there. But the difference is that with PHP you don’t HAVE to use objects. The true definition of flexibility is when you are free to build as the situation warrants.

3) There are no tools for easing debugging/development problems.
Simply not true. For example, Zend developed Zend Studio which has all of the features of a modern IDE; profiling, debugging, etc. There are also several open source applications that aide in this arena. With the Eclipse PHP plugin coming along, this argument loses even more steam.

4) PHP is slow
Can be true, doesn’t have to be. If you take PHP out of the box, throw it on a web server and leave it there you will see lower performance. But if you build an application that understands caching, loads only what it needs and uses a code cache such as Zend Platform or APC you can get extremely fast performance. For example, using a caching mechanism in Zend Platform I recently demonstrated reducing execution time on a certain program from 600ms to 7ms.

5) There are no serious applications written in PHP.
While this is not true (many companies are using PHP in mission critical enterprise applications and there are several large scale applications available for use) the problem is that this statement diverts attention away from what the real question ought to be. The real question is “What is keeping serious applications from being developed in PHP?” The former statement is often used in a context of ridicule, guile or wholesale discrimination and seldom backed by fact.

There are very few reasons that should keep an enterprise level application from being developed in PHP from a functional perspective. In terms of back office integration today’s dependence on XML makes that concern irrelevant. If your concern is that your enterprise runs on Java then Zend’s Java Bridge built into Zend Platform gives you the option of using PHP to build your web based front end to your Java-based enterprise. Even in Microsoft environments PHP has COM and .NET integration points with Microsoft compatible platforms.

When I look at the php.net’s function reference I see 182 individual modules that are supported natively by PHP. There is support for several databases (not just MySQL), LDAP, IMAP, PDF, XML, shared memory, SSL, bindings to several multi-media engines, SOAP, COM, .NET, multiple compression/encryption schemes, JSON, non-blocking IO for both streams and sockets, XSLT, NIS, Shockwave and on and on and on. These are not the hallmarks of an insignificant programming language.

And this is only the beginning. PHP, with the help of Zend, has been given enterprise credibility via partnerships with IBM, Oracle and Microsoft. These are not industry lightweights. And they are companies who recognize that PHP is more than a simple hackers’ language. They see that PHP has the potential for great things in the enterprise space.

I would argue that once most of these points have been fully considered there are few significant barriers to building serious applications in PHP.

If, after reading this, still think that PHP has no place in the enterprise, please email me at kevin@zend.com. Your thoughts and responses are both anticipated and welcome.

Making Tables Read-only in oracle

In Oracle, you can only control read/write capability for an entire tablespace, not for a single table within a tablespace. So, if you want all the tables in a tablespace to be read-only, use the following command:


ALTER TABLESPACE READ ONLY;

To reverse the change and set all the tables in the tablespace back to read-write mode, use this code:


ALTER TABLESPACE READ WRITE;

Despite that limitation, you can simulate a read-only table by simply preventing all table modifications using a trigger. To do that, create a trigger as follows.


SQL> create or replace trigger emp_sal_read_only
2 before insert or update or delete
3 on emp_sal_tbl
4 begin
5 raise_application_error (-20001, 'Table EMP_SAL_TBL is read only,
You cannot make changes to the data.');
6 end;
7 /
Trigger created.

Here's a test command that tries to alter the data, and the resulting output:


SQL> DELETE FROM EMP_SAL_TBL;
DELETE FROM EMP_SAL_TBL
*
ERROR at line 1:
ORA-20001: Table EMP_SAL_TBL is read only, You cannot make changes to the data.
ORA-06512: at "SRIDHAR.EMP_SAL_READ_ONLY", line 2
ORA-04088: error during execution of trigger 'SRIDHAR.EMP_SAL_READ_ONLY'
source: devx.com

12/27/06

Graph Theory

These days , I am working on graph theory. I have borrowed some books from the school's library. It's cool.
I don't have time for Ancient Persian translation.

License

Today I put a license on this blog:
Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.

Ancient Persian translation:
الیوم ،تصدیقی بر این وب نوشت نهادم. متن تصدیق را در سایت مربوطه مشاهده توانید نمود.
.

Mr. Saberi and his mobile phone

Finally Mr. Saberi our mathematics teacher , bought a cell phone. A Sony-Ericsson's Walkman. lol. He was the only teacher who hadn't a mobile phone by now.(though the price of mathematics teachers as a private teacher is extremely high, both they may be a little stingy, of course Mr. Saberi was buildin' a house by now and he is not a stingy person) We could grab his number....Dirty sms messages !!! ;)
--------
َAncient Persian translation:
بعد از گذشت ازمنه ای بس دراز، جناب مستطاب حسن صابری نیک ،معلم ریاضیاتمان نیز دورگویی قابل حمل( و در اصطلاح موبایل) مبایعه نمود.یک سونی اریکسون واکمن.او یگانه دبیری بود که تا به امروزچنین وسیله ای از آن خود نداشت.(گویند که معلمان ریاضی در کلاس های خصوصی خود ثمن عظیمی از دانش آموزان طلب می کنند.پس ممکن است کمی گران کیسه و خسییس باشند. علی أی حال آقای صابری تا به حال به ساختن منزلی برای خویش مشغول بود و هرگز انسان لئیمی نیست.) توانستیم رقم او را از گوشه وکنار پیدا کرده و پیام های کوتاه با مضامین نامتعارف برای ایشان بفرستیم.ـ

12/26/06

Christmas, New year and finishing programming

Merry Christmas and happy new year 2007.
I am not a programmer anym0re. It's not so bad. for me, as a programmer.
I am very sad right now. I think that a programmer is a programmer for ever. But i am not a programmer now. I don't study php or program with this lovely language. So i use this blog for my personal notes.
Sorry for programmer readers.

12/20/06

Zend php 5 Certification exam tips-- strings Part II

· str[c]spn (string str2,string str2[,int start[,int length]])

· strspn () matches a string against a white list mask of allowed characters. Returns the length of the initial segment of the string that contains any of the characters specified in the mask.

$string="133445abcdef";

$mask='12345';

echo strspn($string,$mask); // 6

· strcspn() is like strspn but takes a blacklist instead of a white list.

· Both strspn and strcspn accept two optional parameters that define the starting position and the length of the string to examine. i.e.:

$string='1abc234';

$mask='abc';

echo strspn($string,$mask,1,4); //3

In the example above, strspn() will start examining the string from the second character(index 1) and continue for up to four characters.

· mixed str_replace(mixed search, mixed replace , mixed subject [,int &count])

using count:

$a=0; //initialize

str_replace('a','b','a1a1a1',$a);

echo $a; //3

if we wanna search and replace more than one needle at a time, we can pass first two args as arrays.

Example1: echo str-replace(array("hello","world"), array("bonjour","monde"),"hello world");

Example2: echo str_replace(array("hello,world),"bye","hello world");

In the first example the replacements are made based on array indices.

The first element of the search array is replaced by the first element of the replacement array, and the output is bonjour monde. In the second example, only the needle argument is an array resulting Bye Bye.

· Case insensitive str_replace = str_ireplace()

· If we need to replace a portion of a needle of which you already know the starting and ending points:

Mixed substr_replace(mixed string, string replacement, int start[,int length])

Substr_replace Replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. The result string is returned. If string is and array, then array is returned.

If start is positive, the replacing will begin at the startth offset into string.

If start is negative, begin at the startth char from the end of string.

If length is given and is negative, represents the number of chars from the end of the string at which to stop replacing. If not given, default is strlen($str).

Substr_replace examples:

Substr_replace($var,'abc'0) // all of $var with abc

Substr_replace($var,'abc',0,0 // right at the beginning.

· The combination of substr_replace and strpos is a powerful tool:

$user='danrah@gmail.com';

$name=substr_replace($user,' ', strpos($user,"@");

echo "hello ".$name; // hello danrah

12/19/06

Zend php Certification exam tips-- strings Part I

· There should be no space before the ending statement of heredoc

· The only exception we can't use heredocs is in class properties:

class hello{

public $greeting=<<<>

Hello

STRING;

} //parse error

· We can not escape a brace ({) in double quotes with a backslash. Instead, we should escape the dollar sign inside:

{/$

· strlen() is binary-safe. It means that counts all of the characters regardless of their value.

· \0 is counted once by strlen()

· Strtr() translates certain characters:

Form 1: string strtr(string str,string from, string to)

Form 2: string strtr(string str,array replace_pairs)

In Form1, to and from should be the same size.

· strcmp() and its family are extremely important in exam.

· Substr_compare() :

Int substr_compare(string main_str, string str, int offset[,int length[,bool case_insensitivity]])

Compares main_str from position offset with str up to length chars returns <0>

· Simplest way to search inside a string: strpos and strstr families

· Strstr is important. Read the manual carefully

· Strpos is important too. if needle is not found, strpos will return Boolean false. The important thing about strpos is that we should use === for comparison because if position was 0th char, then == interprets that as false.

· Case insensitive strstr: stristr

· Case insensitive strpos: stripos

· Strpos finds position of last occurrence of a char In a string:

echo strrpos('123123,'123"); //3

12/15/06

Zend Cert Tips --PHP Basics

  • Getting string offsets, {} is a better practice than [] note that indices are started from zero
  • Indirect references to variables(variable variables):

$name="John";

$$name="Registered User";

echo $john; //prints registered user

echo $name; //prints John

Variable variables are a very powerful tool, and should be used with extreme care, not only because they can make your code difficult to understand and document, but also because their improper use can lead to some significant security issues.

Because of the availability of variable variables, it is indeed possible to create variables whose names do not follow the constraints. This is also possible

by defining the name between braces:

$name = '123';

/* 123 is your variable name, this would normally be invalid. */

$$name = '456'; // Again, you assign a value

echo ${’123’}; // Finally, using curly braces you can output ’456’

A technique similar to variable variables can also be used to hold function names

inside a variable:

function myFunc() {

echo ’myFunc!’;

}

$f = ’myFunc’;

$f(); // will call myFunc();

Clearly, this technique should be used with as much care as variable variables,

opportunities for mistakes and security issues it raises are quite significant.

  • In heredoc ending statement, semicolon is optinal but newline is registered and no space should be before this statement:

$string= <<<>

Str

STRING; //no space should be b4 this

  • Using each() to work like foreach

$players=array("Joe","Jack","Bill");

Reset($players);

While(list($key,$val(\)=each($players)){

Echo "#$key=$val \n";

}

  • The third argument of define() sets the case insensitivity of the constant, default 1(insensitive)
  • Valid composite assignment operators:

+= -= %= ^= .= &= |= <<= >>=

  • The match in the switch statement uses == not ===
  • For "for" loop we can supply more than one expression for each of the three args by using commas to delimit them.
  • Using "global" keyword is not recommended because of various reasons such as misbehaving with assigning values by reference, not supporting unset() and so on. We should use $_GLOBALS[] instead


Zend Cert Tips

As I mentioned earlier, I am studying for ZCE exam. I want to digitalize my notes (which are mostly tips) and post them to this blog. So they can be good resources for readers and for me to review them. The notes are from:

1. Manual

2. PHP5 Power Programming

3. Zend PHP5 Certification study guide

4. Zend PHP Certification study guide

5. PHP5 and Mysql Bible

I try to post new tips daily.

The tips are by subject and start from PHP Basics

They conform to Zend PHP5 Certification Exam topics listed at Zend.com

I don’t post something like what is a control structure or how to print something to the page and something like that.

I hope them to be useful for both u and me

;)

Zend PHP 5 Certification Study Guide Review

As i mentioned earlier, I got the book after a long time. I have read two chapters by now. It is a great book, showing the hidden parts of PHP5. But there is a tremendous problem . no Practice tests are given in the book.Instead, There is an online Mock exam which is not suitable for everyone.
The Certification Study Guide for PHP4 had sample tests with a companion:
Zend PHP Certification Sample Exams.
I think Zend wanna spread digital World ;)

12/14/06

Zend PHP 5 Certification Study Guide

Today, I found a pdf version of the Zend PHP5 Certification Study Guide. I am readin' it before my printed version arrives. Cool Book ;)

12/9/06

Something Frustrating about Zend PHP5 Certification

Read This Two Posts from Zend.com forum:
post 1 Study Guide is not useful
Post 2 Yellow Pages Problem
I think that PHP5 Certification is still incomplete.
we should wait ;)

Microsoft and PHP

Making PHP on Windows Work
by Andi Gutmans

Do You PHP ?

Do you php? (by rasmus lerdorf)

Design and Analysis of Distributed Algorithms

Download this book for free:
http://rapidshare.com/files/3693203/0471719978.rar

12/8/06

Mysql Customers

for a list of mysql customers(including google and Yahoo), take a look here:
http://www.mysql.com/customers/

Import MS Access Data to MySQL 5

Introduction


In an era where data becomes volumetric in every business, much attention has been given to proper database management and the ease of data access. Businesses that use MS Access begin to look for an alternative which allows better database performance, higher reliability, higher flexibility, yet inexpensive.


With the numerous choices available in the market, considering you don't want to put too much investment on it, only one, MySQL, stands out from the crowd. MySQL's flexibility allows you to deploy it cross various platforms, it also allows multiple user access concurrently. If you wish, you can still continue to do your data administration through Access as a front end. However, despite the various MySQL's features overtaking Access, whether or not to migrate your data from Access to MySQL still need an in-depth consideration.


In this article, I will discuss whether or not to migrate your MS Access data to MySQL. Then, I will cover about the considerations, planning, and preparations which should made before migrating your data. After all the planning and preparation stages has been finished, I will illustrate to you how the migration can be done with the help of Navicat, a MySQL database administration GUI.



MySQL versus Access


When you start to think of whether to use Access or MySQL, a very first point to think about is that what you need. The features of MS Access and MySQL are almost in two different directions: MS Access can only be deployed in Microsoft Windows while MySQL is cross platform; MS Access is a single-user application while MySQL is a multi-user application. To help you to decide whether or not to keep using MS Access or migrate your data from MS Access to MySQL, we will illustrate some scenarios that you should migrate or should not.



Migrate your MS Access data to MySQL when



  1. You want your data to be deployed with more flexibility. Data in MySQL can be accessible to more users through the web. With MySQL, people can use client programs or other administrative tools to get access to your database by authentication. MySQL can also be integrated with Web Server by web programming languages. This provides a more flexible choice other than MS Access alone. You can get your data from MySQL remotely from anywhere you want disregarding the platform, provided that the database is connected to the Internet and you have to login names for it.

  2. You are not the only person who controls the data. MS Access is a single user program for local use, although it has some sharing features, your data cannot be accessed concurrently in MS Access. MySQL is a multiple-user program, it's suited to the situation where you are not the only person who is controlling the data. MySQL is designed to work well in a networked environment and is capable to serve a number of clients.

  3. You want your data secured and only accessed by authorized people. MS Access data is stored in a local machine, whenever the machine is left unattended, any foreigner may steal your data by copying it to a disk. Although MS Access do allow users to set passwords to a database, it is not a necessity and many people neglect the process. MySQL requires authentication before opening connection to a database, this enhances the security issue. It also allows user privilege settings, this can help database administrator easily manage the actions for each particular user can perform.

  4. Your database is large.

  5. You are not going to use Microsoft Windows anymore. Since MySQL is cross-platform, you can install your MySQL on more than 20 platforms including Linux distributions, Mac OS X, UNIX, and Microsoft Windows.

  6. You want an open source database. MySQL can be obtained for free while MS Access cannot. MySQL is now under the GPL license. You can obtain a free copy of MySQL if you are not using it for commercial purpose. For commercial organization, the license is inexpensive compared to other databases in the market.



Do not migrate your MS Access data to MySQL when:



  1. you want your data be easily portable. Since MS Access is a local based program, you can take your data with your wherever you like by just copying the file onto a disk. The file can be opened with an MS Access program installed in another computer;

  2. you only need single user access to database;

  3. you prioritize the use of MS Access reporting feature more than the database features of MySQL;

  4. you feel very comfortable with the performance of MS Access.



After thorough understanding of the pros and cons of MS Access and MySQL, you should now able to decide whether or not to move your data to MySQL. If you have now confirmed your interest to migrate your data, the following sections will teach you how to do so.



Before Migration


To start using MySQL, a good planning is important as there is some incompatibility between MS Access and MySQL. To transfer the data successfully, there a few points we have consider. One of the important data incompatibilities we must consider is the column type and data format. Although most of the column types in MS Access and MySQL are compatible with each other, the capacity of specific column type may differ. For example, the type varchar in MS Access is not the same with the type varchar in MySQL. MS Access' varchar holds more characters then that in MySQL. In this case, we have to use text in MySQL to hold up characters in MS Access' varchar instead.


A typical example is the Date Format. In MS Access, date is stored as MM-DD-YYYY, whereas in MySQL, the date is stored as YYYY-MM-DD. Care needs to be given to those fields during conversion.


Other points we have to consider are the differences in the built-in functions, user defined functions, and maintenance.



It seems that there is a lot which we must consider for the migration. However, the real story can be simplified with the help of some database administrative tools.



Currently, there are a wide variety of tools available in the market to suit our needs. Here I will look into Navicat which I personally thinks stands out from the crowd.



Transferring your MS Access data to MySQL through Navicat


Navicat (http://www.navicat.com/download.html) supports imports from various file formats such as text, csv, XML, Excel, MS Access, HTML and some others.


Navicat has a function Import Wizard. In the table view, click the icon Import Wizard.



Animated graphical demonstration: http://support.navicat.com/animations/import_access.gif



In step 1 of the Import Wizard, specify the file type you would like to import. In this case, we choose MS Access database .mdb file. Click Next to proceed.



In step 2, choose the location of the access file. Once you have chosen the location of the file, all your tables in your access files will be shown in the table name box. Choose the tables which you would like to import. In this case, there is only one table present.



The import wizard will skip steps 3-5 and jump to Step 6. In this step, you can manually change the data type of the field, the value shown is the automatically generated type detected by the system.



The import wizard will skip Step 7-9 and jumped to Step 10. Choose Append: add records to the destination table and click Execute to start the converting process.



With the help of Navicat, the conversion process becomes unexpectedly easy. You can finish all the configuring process within one minute.



Navicat not only helps import MS Access data onto MySQL but also contains functions which MS Access has and even more.



Conclusion


This article has discussed the advantages and disadvantages of switching MS Access to MySQL. Whether or not to migrate your data will, of course, depend on your own needs.



Free trial version - http://www.navicat.com/download.html



Navicat Animated Demo - http://support.navicat.com/visual_tutorial.php

source: phpbuilder.com

Mysql Syntax

An easy to understand guide to MySQL syntax:
http://www.phpfreaks.com/MySQL_Reference/Syntax/3.php

Google Using Ajax again

after google trends, now google translation is using ajax.

12/7/06

Another SPl Example

Another SPL Example Class:
http://www.phpclasses.org/browse/package/3549.html

12/4/06

SPL Example

SPL Example Code
Download

Microsoft Takes the Windows Vista Road

After five years of hard work and 9 billion dollars worth of investments, Windows Vista fails to provide an answer to a simple question: “Who needs it?”

Ever since 2002, Microsoft has not missed a single chance to tell how revolutionary, how reliable and how special the new Windows would be (dubbed Longhorn up to 2005).

However, under the pressure of time, competition and many other factors, some services have been eliminated; others have been rethought while others have not even been mentioned again.

The final result? An operating system whose hardware requirements are met only by half of the computers currently used in the US (there’s no point mentioning the rest of the world), an OS which brings several significant transformations to what Windows has meant so far.

The first and most talked about change that Windows Vista brings is its new graphic interface, also known as Aero (those inclined toward sarcasm haven’t been able to refrain from commenting that Aero is inspired by Apple).

In order to support Aero, a PC must have at least 1GB of RAM and a video card of 256 MB RAM. Although the new interface is spectacular, it’s hard to believe that there will be a great number of companies or users willing to pay for it.

The interface is not the only major change though that Windows Vista brings.

Windows vista is the first OS designed and created after Bill Gates’s famous e-mail, through which he was asking employees and colleagues to be especially careful about security. Thus the long, 5 year journey began, with this concept of trustworthy computing in mind; this weekend brought it nearer to its end.

Microsoft says Windows Vista is the safest operating system ever. The users’ login system management has been modified almost completely, applications no longer have easy access to Windows’ basic components and these are but few of the changes the Redmond company has made.

Microsoft has wanted to lose its label of unsafe OS so badly, acquired through Windows 95 and Windows 98, that it invested heavily in security, purchasing companies and products and even starting a bit of a conflict with established producers such as McAfee and Symantec.

Nevertheless, from what has been shown so far, Windows Vista doesn’t get rid of the necessity to install an anti-virus, a firewall and even an antispyware program. That all this comes under the name of MicrosoftOneCare is a matter of personal taste, but users should not hold the wrong impression that, once Windows Vista installed, their security problems become history while their PCs become bona fide fortresses before hackers.

Another function that Windows Vista hopes to seduce consumers with is a new search engine that those prone to sarcasm once again say is inspired by Apple. Due to pressure coming from Google, Microsoft has invested enormous sums of money not only in MSN Search, but also in the new Windows Live Search platform, and implicitly, in its sequel.

Despite the effort, the kind of search that Windows Vista is proposing is still inferior to that provided by Google Desktop Search, a free application offered by the Google company.

To conclude, Windows Vista is a sum of useful functions and updates that a 2006 OS would be expected to bring, but it doesn’t provide anything more than what Windows XP itself offers, for example.

The latter’s advantage is precisely the fact that it has been on the market for five years, and that in this time period all programs, both possible and impossible, have been designed and launched, programs which can control virtually any aspect, from graphic interface to an operating system’s security.

As it is, Gartner itself has not given Windows Vista much credit compared to Windows XP. The analysis company estimates that PCs running on Vista will not outnumber those running on XP before 2010.

Has Windows Vista arrived too late for Microsoft? Considering the hardware specs, the market is not prepared yet for such an OS, but analyzing things from the perspective of functions offered by Vista, there isn't a single one customers would crowd stores for.

Maybe it would have been safer for Microsoft to concentrate on a Windows XP SP3 now and launch Windows Vista at a later time. All these options are no longer unavailable unfortunately, and history can’t be changed. Microsoft has taken the Vista road: there’s no turning back and all that’s left for the company is to realize where it’s taking it.

playfuls.com

12/3/06

This is For You ;)

Bye Bye awardspace

I am using award space currently. it is a free hosting service. so, it is not powerful. i want to redirect this address to drahmanzadeh.blogspot.com

ADSL after a long time

ADSL is available now in our region. I went to buy an ADSL line. But they said that we can't provide ADSL for your Phone Number that starts with 3 . I asked why? they answere: because local telephony doesn't let us to start.
Technological Country=Iran
lol