Thursday, August 23, 2007

PHP With Postgresql

Generally with PHP My sql is used. PHP is the most widely used Apache module available and provides a strong platform for Web application development. However, most people who use PHP with open source databases use PHP with MySQL.

Example of PHP with Postgresql:

Making the Connection

There are two direct ways to make a connection to PostgreSQL using PHP. They are pg_connect() and pg_pconnect(). The syntax of the two connections is very similar. However, functionally, they are a bit different. The pg_connect() function will create a new connection for each instance of the function. On the other hand, pg_pconnect() will reuse an existing connection to PostgreSQL if one is available.

The following is a simple example of opening a database connection to PostgreSQL:

$connection = pg_connect("dbname=mydb user=myuser host=localhost");
?>

To do the same with pg_pconnect, the syntax is nearly identical:

$connection = pg_pconnect("dbname=mydb user=myuser host=localhost");
?>

The previous examples open a connection to the database "mydb" on the local host, as the "myuser" user. If the user= parameter is omitted, the user that will be authenticated is the system user that your Web server is running as (for example, "nobody").

The next step would be to actually send a command or query to the PostgreSQL database. This is done in conjunction with the pg_connect() function by using the pg_exec() function.

$connection = pg_connect("dbname=mydb user=myuser");
$myresult = pg_exec($connection, "SELECT * FROM id,username,fname,lname where id > 100");
?>

The previous example will connect and execute a query, but not much else. You only have to pass the $connection variable if you have more than one connection to choose from (for example, if you have opened two connections with the pg_connect() function). Therefore, the following code would function identically, if you intend on having only one connection:

pg_connect("dbname=mydb user=myuser");
$myresult = pg_exec("SELECT * FROM id,username,fname,lname where id > 100");
?>

If you wanted to make this code a bit more robust, you could add some exception handling:

$connection = pg_connect("dbname=mydb user=myuser");
if (!$connection) {
print("Connection Failed.");
exit;
}
$myresult = pg_exec($connection, "SELECT * FROM id,username,fname,lname where id > 100");
?>

Now we have a connection to PostgreSQL that will alert you if the connection fails. Also, we are executing a simple query. We are not, however, processing the results of the query we sent. Thus, we will want to add some logic on the result set as shown in the following bit of code:

// make our connection
$connection = pg_connect("dbname=mydb user=myuser");

// let me know if the connection fails
if (!$connection) {
print("Connection Failed.");
exit;
}

// declare my query and execute
$myresult = pg_exec($connection, "SELECT * FROM id,username,fname,lname where id > 100");

// process results
for ($lt = 0; $lt < pg_numrows($myresult); $lt++) {
$id = pg_result($myresult, $lt, 0);
$username = pg_result($myresult, $lt, 1);
$fname = pg_result($myresult, $lt, 2);
$lname = pg_result($myresult, $lt, 3);

// print results
print("User Id: $id
\n");

print("Username: $username
\n");

print("First Name: $fname
\n");

print("Last Name: $lname
\n");

}
?>

Magento, Your Next Ecommerce Plateform

The updated open source for the ecommerce will be introduce shortly in Aug-2007. Name of this open source is Magento. It has improved features of Ecommerce as well as bloging.

Some exciting things about magento are listed below:

No Constraints:

As a professional open-source eCommerce solution, Magento allows the flexibility to create an online store that's exactly what your business needs without extra clutter or constricting design limits. Never feel trapped in your eCommerce solution again.

Completely Scalable

Whether your store grows overnight or over a year, don't spend valuable time worrying about your solution not growing with you. With Magento, your site is completely scalable.

Professional and Community Support

Unlike many other open-source eCommerce solutions available, Magento offers professional, reliable support, as well as the help of its passionate community.

Smooth Integration

Integrating third-party solutions should never be a hassle. Magento's easy integration will help save you time and resources as you create a customized store around your business needs.

Cutting Edge Features

Don't pay extra for features like product tagging, multi-address shipping or product comparison systems. Instead, get these and more right out of the box with Magento.

There are three catagory of features of Magento

1. Customer Features:


2. Administration Panel


3. General

Saturday, August 11, 2007

HOW TO SET RULES IN POSTGRESQL?

PostgreSQL supports a powerful rule system for the specification of views and ambiguous view updates. Originally the PostgreSQL rule system consisted of two implementations:

  • The first one worked using tuple level processing and was implemented deep in the executor. The rule system was called whenever an individual tuple had been accessed. This implementation was removed in 1995 when the last official release of the PostgreSQL project was transformed into Postgres95.

  • The second implementation of the rule system is a technique called query rewriting. The rewrite system} is a module that exists between the parser stage and the planner/optimizer. This technique is still implemented.

Procedure For creating rule:

We can define new rule by the command listed below:

CREATE RULE — Defines a new rule
CREATE RULE name AS ON event
TO object [ WHERE condition ]
DO [ INSTEAD ] [ action | NOTHING ]
Where the inputes indicates :

name

The name of a rule to create.

event

Event is one of select, update, delete or insert.

object

Object is either table or table.column.

condition

Any SQL WHERE clause, new or old can appear instead of an instance variable whenever an instance variable is permissible in SQL.

action

Any SQL statement, new or old can appear instead of an instance variable whenever an instance variable is permissible in SQL.

The Postgres rule system allows one to define an alternate action to be performed on inserts, updates, or deletions from database tables or classes. Currently, rules are used to implement table views.

The semantics of a rule is that at the time an individual instance is accessed, inserted, updated, or deleted, there is a old instance (for selects, updates and deletes) and a new instance (for inserts and updates). If the event specified in the ON clause and the condition specified in the WHERE clause are true for the old instance, the action part of the rule is executed. First, however, values from fields in the old instance and/or the new instance are substituted for old.attribute-name and new.attribute-name.

The action part of the rule executes with the same command and transaction identifier as the user command that caused activation.

For Example Look at the below shown example:

Make Sam get the same salary adjustment as Joe:

CREATE RULE example_1 AS
ON UPDATE emp.salary WHERE old.name = "Joe"
DO
UPDATE emp
SET salary = new.salary
WHERE emp.name = "Sam";
At the time Joe receives a salary adjustment, the event will become true and Joe's old instance and proposed new instance are available to the execution routines. Hence, his new salary is substituted into the action part of the rule which is subsequently executed. This propagates Joe's salary on to Sam.

Make Bill get Joe's salary when it is accessed:

CREATE RULE example_2 AS
ON SELECT TO EMP.salary
WHERE old.name = "Bill"
DO INSTEAD
SELECT emp.salary
FROM emp
WHERE emp.name = "Joe";

Deny Joe access to the salary of employees in the shoe department (current_user returns the name of the current user):


CREATE RULE example_3 AS
ON
SELECT TO emp.salary
WHERE old.dept = "shoe" AND current_user = "Joe"
DO INSTEAD NOTHING;

Create a view of the employees working in the toy department.

CREATE toyemp(name = char16, salary = int4);

CREATE RULE example_4 AS
ON SELECT TO toyemp
DO INSTEAD
SELECT emp.name, emp.salary
FROM emp
WHERE emp.dept = "toy";

All new employees must make 5,000 or less

CREATE RULE example_5 AS
ON INERT TO emp WHERE new.salary > 5000
DO
UPDATE NEWSET SET salary = 5000;


Friday, August 3, 2007

10 things a PHP IDE has to have

There are so many PHP IDE's out today and it is very hard to choose between them. In my investigations I have found that though there are many they all fall short when it comes to the basic needs of a PHP developer.
Before I continue and review some of those PHP IDE's here is a list of 10 things a PHP coding program has to have.

  1. One-click project creation by choosing a directory with. Too many PHP IDE's have multi-step project creation. Some even have strange functions where you have to add files to the project and delete them. Adding and deleting a file from a project should be as easy as going to the file system and moving or removing the file. I don't want to delete a file from a project and find it hanging out in the project folder later. Some might think this is cool, but it is not.
  2. Local filesystem viewer that shows the filesystem tree without having to enter a drive letter. If I cannot see the file system from the IDE it's uninstall and delete followed by some violent thoughts directed at the software maker.
  3. A PHP debugger that works out of the box with a local webserver. No PHP IDE has this yet. I consider it the holy grail of the PHP software world. No matter how much support software manufactures offer it never covers this aspect of using an IDE enough. Frequently the only reason for purchasing or using an IDE rather than a text editor is to get debugging features.
  4. A HTML toolbar. Why do PHP IDE makers think PHP developers want to type out and can remember all HTML? After all they are buying or downloading the IDE to ease the task of having to type things character by character. CSS is also much more important nowadays as is javascript, they should be included.
  5. Price is in second place after debugging. When you think about it you might see that the top commercial IDE makers are probably guilty of price fixing. Why they think that PHP developers will pay $300 for their software is beyond me. I myself would not pay that kind of money for a Java program that is buggy and runs slow as molasses. You want three hundred bucks? Give me everything on this list in a blinding fast program written in C , Delphi or Visual Basic.
  6. Drag and Drop text that does not bug out when used. All PHP IDE's seem to have this in common. Using drag and drop or marking long rows of text cause jumping, jitter and the disappearance of the pointer. Some even scroll to a "home" area on the screen when too much text is marked.
  7. Fast start times. Okay, let's skip the slow Java debate and go straight to the core. I want my 2.5gz processor to start the IDE in the same time that it can start Word or Open Office. Waiting a minute is ridiculous. Again here commercial vendors may want to take note. If the program costs more than $300, I deduct $10 from the retail price for each second that it takes to start the program.
  8. File backups on save and timed backups of working files. I cannot stress how important this is. Without backups the program becomes a danger to use. I always find myself making several copies of files as I work to give me a stepping back or history capability. I would be nice if an IDE had a savable history or versioning capability. But plain backup is a must.
  9. A TO DO list function. It should be simple with a title and text body. The list should appear per project. I get tired of seeing TO DO lists functions that require that I do more than just jot down the thought in my head.
  10. Intellisense. This is a must. But also one has to wonder why regular HTML is never included in intellisense. Intellisense I feel is being used as an excuse for not including the other things need to produce a proper PHP application
Source: PHP Developer

K-Meleon: The new Gecko rendering engine developed for Mozilla

About K-Meleon

K-Meleon 1.0 is released under the GNU General Public? License. K-Meleon uses the Gecko rendering engine developed for Mozilla which provides excellent support for current HTML, CSS and DOM standards. This version contains portions of Mozilla 1.8.

What's New, Improved and Fixed in This Release

New

  • Mozilla 1.8.0.5 backend.
  • Native Dialogs for UI improvement and preferences support for cookies, passwords, permissions.
  • Localization of cfg files.
  • Find bar.
  • Autocomplete in URL bar, improved navigation, security state dependent color.
  • Site icons support and drag&drop from URL bar.
  • Open/Save Dialog for download.
  • Download preferences panel.
  • Advanced preferences panel.
  • Possibility to set a custom profile path.

Improved

  • Web search and proxies support.
  • Overall improvements for macros and menus.
  • Title support in history viewer.
  • Bookmarks toolbar support.
  • See the changelog for details.

Fixed

System Requirements

  • Windows 2000, Windows XP and Windows 2003 Server fully supported. Windows 95, 98, 98SE, ME, Windows NT 4.0 generally supported with updated Microsoft libraries.
  • 32 MB RAM minimum recommended.
  • 5 MB of free hard drive space for download. 15 MB of free hard disk space for full installation.

Download

  • The K-Meleon 1.0 installer is available here.
  • A .7z file is available here (you need 7-Zip).

Installation Notes

Installation

    1. If you have previously installed a version of K-Meleon older than 1.0, make sure to uninstall any previous versions before continuing the installation for this version. Uninstalling the previous version will remove all of the configuration and preference files. If you wish to save these files to use with K-Meleon 1.0, please make a copy of all of the directories under "K-Meleon\Profiles" and save them outside the K-Meleon installation directory before uninstalling K-Meleon.
    2. It is recommended that you exit all programs before running the Setup program.
    3. Double-click on the kmeleon10.exe file to start the Setup process. At any time in the process that you need to stop the K-Meleon installation, click on the Cancel button.
    4. Follow the on-screen instructions in the Setup program. When completed, you will be given the option of letting K-Meleon start automatically.
    5. If you wish to use your old configuration and preference files with K-Meleon 1.0, please review the details on Migrating Profiles.

Javascript

  • K-Meleon has built-in support to run ECMAScript (a.k.a. JavaScript).

Java Applets

  • You must first install the Java Runtime Environment (JRE) to run Java applets in K-Meleon. Once installed, K-Meleon automatically detects your JRE installation and no other configuration is necessary.
  • K-Meleon has been tested with JRE 1.5. You can download JRE 1.5 from http://java.com/. To see if JRE is properly installed, type about:plugins in the URL bar. If you see Java Plug-in listed, K-Meleon properly recognizes the JRE.

Internationalization/Multi-Language Support

  • Localisation packages will be available in the K-Meleon Resource area.

Uninstalling

    1. Go to Settings - Control Panel - Add/Remove Programs.
    2. Select K-Meleon1.0 (remove only).
    3. Click on the Add/Remove or Change/Remove button.
    4. Click on the Uninstall button.
    5. Click on the Finish button to close out the uninstall program when it is completed.

Known Issues/Problems

General

  • When viewing web page source from dynamically generated pages, the current source may not match the displayed page.
  • The content of the browser may not be resized properly when moving a windows explorer task bar.
  • When you edit your web search preferences, the menu will not reflect your changes before a restart.
  • The URL bar content is not updated if you go back/previous just after having edited it.

Browser Display

  • Colors do not display properly when monitor resolution is set to 256 colors since Mozilla/Gecko does not provide proper support for 256 colors. See Mozilla Bug #88560.
  • A site not displaying properly is normally caused by one of two issues:
    1. The site is not compliant with current HTML standards.
    2. The display problem is due to a Mozilla/Gecko bug.

Mouse wheel scrolling/Multiple mouse buttons

  • The Mouse Gesture support offered by the new plugin is very limited. Gestures are disabled by default, you can enable them in the plugins section of the preference panel. Users in need of more advanced gestures are advised to use a third-party program, such as StrokeIt.
  • Mouse wheel scrolling does not work with all drivers. If you have problems, try updating your driver or disabling any "helper" programs that your mouse uses.
  • K-Meleon may not recognize secondary control buttons on mice with multiple buttons. If your mouse software permits programming, you may want to try binding those buttons to the respective keyboard commands that K-Meleon uses for navigation.

Third party Plugins

  • Most Mozilla-compatible plugins work with K-Meleon. If you already have Mozilla-compatible plugins installed, K-Meleon will detect and use a number of these plugins. You can download Mozilla/Netscape-compatible plugins from Mozilla here: https://addons.update.mozilla.org/plugins/
  • The most current versions of Flash Player and Shockwave Player support K-Meleon 1.0. To check to see if these are installed properly, visit Shockwave's test site. When installing either program if you are asked for the location of the plugins directory, use the following location: \Program Files\K-Meleon\plugins

Proxies

  • K-Meleon can be configured to work properly with proxies such as Junkbuster that do not support the most recent HTTP specification. By default, K-Meleon tries to use HTTP 1.1. To use K-Meleon with a proxy that only supports HTTP 1.0, change the HTTP version under Edit - Preferences - General.
Source: K-Meleon