Mar 9, 2011

PHP number of days of a month

If you want to obtain number of days of a month, in PHP, you can use cal_days_in_month function:


int cal_days_in_month ( int $calendar , int $month , int $year )







So, here we have one example of usage of this function:


$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31
    echo "There was $num days in August 2003";
?>

Feb 18, 2011

Introduction to MySQL 5.5

Here (http://dev.mysql.com/tech-resources/articles/introduction-to-mysql-55.html) you will find some notions about MySql 5.5. You'll be familiarized with the news from MySql 5.5:



What's New in MySQL 5.5

It's been a busy year for MySQL. Perhaps you've heard. Here are some recent improvements to the speed, scalability, and user-friendliness of the MySQL database and the InnoDB storage engine that we think deserve their own headlines. Now is a great time to beta test the 5.5 release and give feedback to the MySQL engineering team.

Improved Performance and Scalability

InnoDB Becomes Default Storage Engine
MySQL sometimes gets knocked about features such as as ACID-compliant transactions, foreign key support, and crash recovery. These features are strongest in the InnoDB storage engine, but MyISAM has always been the default, so new users could get the wrong impression. Starting in MySQL 5.5, InnoDB is the default storage engine, so that everyone can see this reliability and stability out of the box. As a bonus, the level of InnoDB in MySQL 5.5 is InnoDB 1.1, a rearchitected InnoDB with many performance and scalability features over and above the built-in InnoDB in 5.1 and before. (Since we are unifying the InnoDB within MySQL using the best and fastest technology, we are phasing out the Plugin versus Built-In distinction; MySQL 5.5 comes with the latest and greatest InnoDB 1.1.) Read more about the latest InnoDB enhancements below.
Better Metadata Locking within Transactions
If a table is referenced within a transaction, no other transaction can perform DDL such as DROP TABLE or ALTER TABLE until the first transaction commits. Previously, the lock was released at the end of a statement rather than the whole transaction. Read more about metadata locking within transactions.
Improved Performance and Scale on Win32 and Win64
If your company uses Windows by itself or in a mixed environment, you probably want to deploy MySQL databases on Windows. To make that a reality, the MySQL team has incorporated a number of Windows-specific features for speeding up and scaling up.
  • Windows API calls for much of the I/O done inside MySQL (a community contribution, hat tip to Jeremiah Gowdy).
  • Ability to build engines and other plugins as DLLs on Windows.
  • Network support for auto-detecting the MAC address (a community contribution, hat tip to Chris Runyan).
  • Much cleanup and simplifying of threading code.

Improved Availability

Semi-Synchronous Replication
This feature improves the reliability of failover, to avoid failing over to a slave that is missing some committed changes from the master. You can choose to have commits on the master node wait until at least one slave has logged the relevant events for the transaction. The semi-synchronous aspect is because the master does not wait for all the slaves to acknowledge, and there is a protocol to avoid the master waiting too long if the slaves fall behind. Read more about semisynchronous replication.
Replication Heartbeat
In replication, the heartbeat is a message sent at regular intervals from a master node to the slave nodes. You can configure the heartbeat period. If the message is not received, the slave knows that the master node has failed. You can now avoid the spurious relay log rotation when the master is idle, rely on an more precise failure detection mechanism, and have an accurate estimation for seconds behind master. (This is a different feature than Linux heartbeat, which is a similar health-checking system for cluster nodes.) To use this feature, you issue commands like:
STOP SLAVE;
CHANGE MASTER TO master_heartbeat_period= milliseconds;
START SLAVE;
SHOW STATUS like 'slave_heartbeat period'
SHOW STATUS like 'slave_received_heartbeats'

Improved Usability

SIGNAL/RESIGNAL
The SIGNAL and RESIGNAL statements allow you to implement familiar exception-handling logic in your stored procedures, stored functions, triggers, events, and database applications that call those things. SIGNAL passes execution back to an error handler, like THROW or RAISE statements in other languages. You can encode the error number, SQLSTATE value, and a message in a consistent way that can be interpreted by an error handler in the calling program. RESIGNAL lets you propagate the exception after doing some amount of error handling and cleanup yourself. With RESIGNAL, you can pass along the original error information or modify it. Read more about SIGNAL/RESIGNAL.
More Partitioning Options
With the new RANGE COLUMNS and LIST COLUMNS clauses of the CREATE TABLE statement, partitioning is now more flexible and also can optimize queries better. Instead of expressions, you specify the names of one or more columns. Both of these clauses let you partition based on DATE, DATETIME, or string values (such as CHAR or VARCHAR). Partition pruning can optimize queries on tables that use RANGE COLUMNS or LIST COLUMMS partitioning, and WHERE conditions that compare different columns and constants, such as
a = 10 AND b > 5
or
a < "2005-11-25" AND b = 10 AND c = 50
Read more about COLUMNS partitioning.
Performance Schema
The Performance Schema feature involves an optional schema, named performance_schema, with tables that you can query to see intimate details of low-level MySQL performance. You can get information about performance right at that moment, or various amounts of historical performance data. You can clear the data to reset the figures, filter and format the data using WHERE clauses, and generally interact with it using all sorts of SQL goodness. Performance Schema data now also includes details about the InnoDB storage engine. Read more about Performance Schema.

What's New in InnoDB

To make a long story short: it's all about performance and scalability! To those who enjoy trying all permutations of configuration settings, we apologize in advance for making so many of these improvements take no thought or effort at all.

Performance Improvements

At this year's MySQL Conference & Expo, you'll hear about the InnoDB Plugin 1.0.7, the first production-ready (GA) release of the InnoDB Plugin. Most of the enhancements listed here are from InnoDB 1.1, which is part of MySQL 5.5 and thus is still in beta. Download MySQL 5.5 and try them out.
Improved Recovery Performance
One of InnoDB's great strengths is its ability to reliably recover data after any type of crash that affects the database. But this cleanup and checking makes the next restart take longer. Well, cover up your sundial. Put away your hourglass. The enterprising InnoDB team has improved the algorithms involved in recovery by a huge amount -- in computer science terms, it's a better big-O number. Now you will need to keep your finger ready on the stopwatch to see how long recovery takes. This feature is available both in InnoDB 1.1 and the InnoDB Plugin 1.0.7. Read more about faster recovery.
Multiple Buffer Pool Instances
With today's buffer pools frequently in the multi-gigabyte range, pages are constantly being read and updated by different database threads. This enhancement removes the bottleneck that makes all the other threads wait when one thread is updating the buffer pool. All the structures normally associated with the buffer pool can now be multiplied, such as the mutex that protects it, the LRU information, and the flush list. You control how many buffer pool instances are used; the default is still 1. This feature works best with combined buffer pool sizes of several gigabytes, where each buffer pool instance can be a gigabyte or more. Read more about multiple buffer pool instances.
Multiple Rollback Segments
This feature is both a performance and a scalability improvement. By dividing the single rollback segment into multiple parts, InnoDB allows concurrent transactions to create undo data (from insert, update, and delete operations) without making each other wait. A happy consequence is that the old limit of 1023 simultaneous inserting / updating / deleting transactions is now much higher, for a total of approximately 128K concurrent writer transactions. This feature does not introduce any incompatibility in the InnoDB file format, and does not require using the newer Barracuda file format. However, the setup within the system tablespace only takes place when the system tablespace is created, so to take advantage of this feature, you must create a new instance (not just a new table or a new database) and import the data into it. Read more about multiple rollback segments.
Native Asynchronous I/O for Linux
This feature enables better concurrency of I/O requests on Linux systems. With asynchronous I/O, an I/O request can be sent off and the thread servicing the query does not need to wait for the I/O to complete; that aspect is delegated to the I/O helper threads. InnoDB already supported asynchronous I/O on Windows systems. On platforms other than Windows, InnoDB internally arranged its I/O calls as if they were asynchronous (leading to the term simulated asynchronous I/O), but behind the scenes the query thread really would block until the request finished. Now true asynchronous I/O support (called native asynchronous I/O so it won't be confused with references to asynchronous already in the source) is available on Linux as well as Windows. This feature requires the libaio userspace library to be installed on Linux. It comes with a configuration option innodb_use_native_aio that you can turn off in case of any startup problems related to the I/O subsystem. Read more about asynchronous I/O for Linux.
Extended Change Buffering: Now with Delete Buffering and Purge buffering
InnoDB uses indexes to make queries faster. Secondary indexes, those on columns other than the primary key, require work (meaning disk writes) to keep them up to date when those those columns are inserted, deleted, or updated. For example, if you run the command DELETE FROM t WHERE c1 = 'something';, and you have a secondary index on column c2, what's the rush to update that secondary index? Its contents might not be in the buffer pool, and maybe the index won't be read for a long time. InnoDB has had an optimization for a while now to delay disk writes for secondary index maintenance when the changes are due to inserts. This delay waits for the index contents to be read into the buffer pool for some other reason, such as a query, where the changes can be made quickly in memory and then flushed back to disk using the normal schedule for writing dirty blocks. When the changes in the buffer pool affect a group of sequential disk blocks, they can be flushed more efficiently than if the data was written piece by piece. Very clever! In InnoDB 1.1, this technique is extended to include the different kinds of writes caused by deletes (an initial delete marking operation, followed later by a purge operation that garbage-collects all the deleted records). This optimization is under your control through the innodb_change_buffering configuration option, which has a new default of all. (We call the optimization change buffering rather than the old name insert buffering; the actual memory structure is still called the insert buffer.) Read more about enhanced change buffering.

Scalability Improvements

The scalability improvements in InnoDB 1.1 revolve around better isolation of threads and mutex contention. These are performance-type improvements that really kick in when the database server is heavily loaded. (For those of you who are not yet experts on InnoDB performance, mutexes are in-memory structures that prevent different threads from interfering with each others' changes to important memory areas like the buffer pool.)
Improved Log Sys Mutex
Previously, a single mutex protected different memory areas related to the undo and logging information. In particular, this mutex blocked access to the buffer pool, while changes were being written there by DDL operations making changes to the data dictionary. Splitting the old log_sys mutex to create a separate log_flush_order mutex means that all of this internal processing can happen with less waiting and less blocking of other operations involving the buffer pool, without any configuration needed on your part. Read more about improved log sys mutex.
Separate Flush List Mutex
Along the same lines, operations involving the buffer pool and the flush list previously were protected by a single mutex, which could cause unnecessary delays. (The buffer pool mutex has historically been very hot, so any other operation that tied up the buffer pool was adding fuel to the fire.) Now the flush list has its own mutex, reducing contention with buffer pool operations and making InnoDB faster without any configuration needed on your part. Read more about separate flush list mutex.
Improved Purge Scheduling
The InnoDB purge operation is a type of garbage collection that runs periodically. Previously, the purge was part of the master thread, meaning that it could block some other database operations. Now, this operation can run in its own thread, allowing for more concurrency. You can control whether the purge operation is split into its own thread with the innodb_purge_threads configuration option, which can be set to 0 (the default) or 1 (for a single separate purge thread). This architectural change might not cause a big speedup with this single purge thread, but it lays the groundwork to tune other bottlenecks related to purge operations, so that in the future multiple purge threads could provide a bigger performance gain. The configuration option innodb_purge_batch_size can be set from 1 to 5000, with default of 20, although typical users should not need to change that setting. Read more about improved purge scheduling.

Better Instrumentation/Diagnostics

InnoDB Stats in Performance Schema
The Performance Schema has been part of MySQL 5.5 for a while now. InnoDB 1.1 is instrumented for the first time for Performance Schema monitoring, with statistics available for InnoDB-specific mutexes, rw-locks, threads, and I/O operations. The data is structured so that you can see everything, or filter to see just the InnoDB items. The information in the performance_schema tables lets you see how these items factor into overall database performance, which ones are the hottest under various workloads and system configurations, and trace issues back to the relevant file and line in the source code so you can really see what's happening behind the scenes. Read more about InnoDB integration with Performance Schema.

Jan 4, 2011

How To Install PHP on IIS 6.0

4thSeptember2007

How To Install PHP on IIS 6.0

posted in IIS 6.0PHP |
I recently decided to experiment with hosting my own blog and after looking at the various packages available decided that I wanted to use WordPress. However, when it came to installing WordPress, I found that there was a lack of really good documentation available if you wanted to use IIS 6.0 as your web server. I also found quite a bit of contradictory information regarding the installation of PHP and MySQL on Windows 2003 - so I decided to write my own. This is the first of a series of articles which will provide a complete walkthrough enabling you to install PHP, MySQL and WordPress on an IIS 6.0 web server.
At the time of writing, the latest stable version of PHP is 5.1.4. Start by downloading the zip package and the Collection of PECL modules from here :http://www.php.net/downloads.php
#Note: You can use the Windows Installer package but it only installs and configures the CGI version of PHP which is not the best solution for an IIS web server; you should try to use the ISAPI version - if you really want to know more about why this ISAPI is preferable to CGI then I suggest you watch this IIS webcast :
TechNet Webcast: Comparing CGI and ISAPI in IIS 6.0 - Level 300
Install and Configure PHP
Start by creating a directory into which you will extract the downloaded PHP files (php-5.1.4-Win32.zip). In this example I’m going to use C:\PHP as my installation directory. Then extract the files from php-5.1.4-Win32.zip into C:\PHP
If you need to use the additional PECL modules then extract the files from ‘pecl-5.1.4-Win32.zip’ into the C:\PHP\ext directory.
Fig. 1
Next locate the file ‘php.ini-recommended’ in C:\PHP and rename it to ‘php.ini’ (without the quotes of course)
Fig. 2
Open the ‘php.ini’ file and find the line which reads extension_dir = “./” and change it to extension_dir = “C:\PHP\ext”. This tells PHP where the various extensions are located and as you can see the default path in the ‘php.ini-recommended’ file which ships with PHP points to the wrong location, so you need to change it.
You also need to add the location of your PHP directory to the server’s PATH environment variable so that Windows knows where to look for any PHP related executables (such as the PHP extension DLL‘s). To do this Right-click on My Computer, click Properties and on the Advanced tab click Environment Variables. In the Environment Variables dialog box, under System variables highlight the Path variable and click Edit.
Fig. 3
Add ‘;C:\PHP’ (be sure to include the semi-colon separator) as shown here and click OK. You need to re-boot the server for this change to take effect.
Fig. 4
If you browse through the ‘php.ini’ file you will see an entry describing the ‘cgi.force_redirect’ property. You will also see a statement telling you that if you are using IIS you ‘MUST’ turn this off. However, this only applies if you are using the CGI version of PHP (i.e. php-cgi.exe) Since we are using the ISAPI version of PHP we can safely ignore this - more details here : http://www.php.net/release_4_1_2_win32.php
You may have also seen various IIS and PHP HowTo guides which suggest that you need to copy your ‘php.ini’ and some other PHP related files to the C:\Windows\System32 directory - this is not actually necessary, as I shall demonstrate later in this walkthrough.

Jan 3, 2011

Internet Explorer. What's next for IE?


Microsoft still isn't talking specifics in terms of what it plans to deliver as part of the next version of Internet Explorer, IE 8.0. But at the Mix '07 conference in Las Vegas, Chris Wilson, platform architect of Internet Explorer, did share some general directions the team is taking with its next release.
In his "IE Past Present and Future" talk on May 1, Wilson told the standing-room-only audience that he wasn't going to show an IE 8.0 feature list, as he "wasn't allowed to."
However, Wilson did tell attendees that Microsoft is planning to require Web site authors to "opt-in" to standards mode when developing IE 8.0 sites.
"Five years ago, no one in the top 200 Web sites was using standards," Wilson said. "Today it is half of the top 200 Web pages."
Wilson acknowledged that he wasn't sure exactly what form this kind of opt-in would take. But asking authors to opt in will "give us freedom to do some great things," he said. By giving Microsoft permission to make IE 8.0 more standards-complaint, authors will take responsibility for breaking pages.
Wilson said to expect Microsoft to be investing across layout, object model and Ajax development fronts in IE 8.0. Specificially, Wilson said Microsoft is investing in making IE 8.0 more compliant with CSS 2.1 layout standards. Microsoft also is working to make the IE 8.0 object model more interoperable with that used by other browsers, and is looking to provide more client-side application programming interfaces (APIs) to support local storage for mash-ups, Wilson said.
Microsoft is planning to make tweaks to IE that will allow developers to more easily add extensions to its browser, Wilson said. He said Microsoft acknowledged that extensions are powerful but potentially "scary."
He also said to expect Microsoft to continue to invest heavily in advancing its Web development toolbar with the next version of IE.
Wilson reiterated that Microsoft continues to see security as its No. 1 challenge with IE 8.0.
Wilson also noted that Microsoft isn't planning to wait another five years to release its next version of IE (as it did when the company waited five years between IE 6 and IE 7). Last year Microsoft officials said they expected to be able to release new versions of IE every 12 to 18 months, but Wilson said an every-two-year schedule was looking more likely.
Wilson said that a number of people have suggested Microsoft release new versions of IE in service packs or as part of the company's monthly security updates, but that Microsoft has ruled that out, as it would make IE too much of a "moving target."
If Microsoft holds to that schedule, IE 8.0 should ship some time in 2008. In January 2007, Microsoft began gathering feedback from developers on what kinds of features and functionality they'd like to see in IE in the future.
Wilson spent most of his talk focusing on the compatibility vs. standards-compliance connundrum which Microsoft has wrestling with its current and future IE releases. With a half-billion IE users out there, Microsoft takes its responsibility seriously to not break sites without solid reasons, Wilson told attendees.
Any feedback for the IE team as it moves forward with its next release?
Kick off your day with ZDNet's daily e-mail newsletter. It's the freshest tech news and opinion, served hot. Get it.

Dec 29, 2010

Textarea in Chrome and Safari

OhOhOhoooo!!!.. how long time have past from my last post!!!

Anyway, today I have one more problem with .css styles. For example, the textarea in Chrome and Safari. As you know, in Chrome you can drag the right-bottom corner of a textarea and resize it. But I have need of textarea element who cannot resize. So,
i put in css styles this:


height: 77px !important;   
width: 330px !important;
                          
And, after that, I have discovered this:
resize: none; /* just for Chrome and Safari */