Thursday, September 23, 2010

Tips for Mysql Fulltext Search

Full-text searching is ideal for extremely large databases that contain thousands or even millions of rows. Computations are performed faster and rows can be ranked based on search relevance, which is returned as a decimal number by MySQL.
Noise words and any words that are 3 characters or less in length such as the, and, etc are removed from the search query. This means that more accurate results are returned. If you searched for “as the people”, then the noise words “the” and “as” will automatically be removed from your query.
In addition to simple searches, full-text searches can also be performed in Boolean mode. Boolean mode allows searches based on and/or criteria, such as “+person +Mitchell”, which would only return all records that contained the words person AND Mitchell. We will look at Boolean searches later in this article.
The query is case-insensitive, meaning that “cat” is ranked the same as “Cat”, “CAT” and “cAT”.

full-text searching is fast, powerful and smart

Fulltext search classifieds by two types.

  • Natural Language search
  • Boolean Search
  • Its have some restrictions.

  • Full-text searches are supported for MyISAM tables only
  • It can be created only for CHAR, VARCHAR, or TEXT columns.
  • Natural Language Search:
    ✔ MATCH (col1, col2, …) AGAINST (“query phrase”
    [ WITH QUERY EXPANSION ] )
    ✔ is supposed to find documents (rows) that are about the topic
    described in the query phrase
    ✔ the query is a phrase in natural human language (e.g. English)

    How to achieve this

    1) We need to add fulltext index in table using fulltext command it can be achieved by two ways.

    CREATE TABLE articles ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), body TEXT, FULLTEXT (title,body) );

    OR

    ALTER TABLE articles ADD FULLTEXT (title,body);

    2) Then invoke the command in MATCH… AGAINST…

    SELECT * FROM articles WHERE MATCH (title,body) AGAINST (‘database’);

    Thats it. Now your search perform faster manner.

    We will discuss boolean and Full text search internal in my next blog.

    Sunday, September 13, 2009

    Start me Up

    Syntax

    PHP’s syntax is derived from many languages—predominantly the C language, but
    Perl has also had a lot of influence on its syntax. With the latest object-oriented additions,
    more Java-like syntax is creeping in as well.
    PHP’s syntax remains simple and easy to understand.

    There are four types of tags to start php line code.

    PHP Standerd Tags:

    1. Standard Tgs
    2. Short Tags
    3. Asp Tags
    4. Script Tags


    Short tags only avalible when they avalibe from short_open_tags in php.ini
    Asp tags only avalible when they avalibe from Asp_tags in php.ini


    Note: Short tags, script tags and ASP tags are all considered deprecated and their use is
    strongly discouraged.

    Anatomy of PHP script:

    1. Every PHP script is made up of statements, Each of these instruction is to be terminated just like in c,java,perl -- with semicolen,
    echo "one";
    echo "two";
    ?>

    2. This requirement is not strict in before close tag statement statement does not require a semicolen
    ex:
    echo "one"
    ?>
    3. The closing tag of a PHP block at the end of a file is optional (Semicolen must).
    echo "one";

    Do not mis interpret

    echo 'Ending tag excluded';

    with

    php echo 'Ending tag excluded';
    <
    p>But html is still visiblep>

    The second one would give error. Exclude ?> if you no more html to write after the code
    4. Comments:
    Php supports Shell type comments

    // Single line comment

    # single line comment

    /* Multiline
    comment
    * /

    /**
    *
    * This is another style
    */
    4. PHP whitespace insensitive . You could not write


    Friday, September 11, 2009

    PHP Installation

    PHP on windows:(WAMP)

    As we already discussed for Server side scripting we need parser, webserver,browser.

    1. Parser ( download from Php.net)
    2. Web server (Download from Apache)
    3. Browser (Default in OS)

    We have to install one by one and need change php.ini and httpd.conf settings.

    PHP Feautures

    PHP support major operating systems ( Linux,Unix,Windows,Sun ,mac etc ) in today's world.
    PHP support all major server (Apache, IIS ,Ligttpd etc).
    PHP also free to use any database. Because its support most of the database.
    PHP ability to display images,PDF,flashes.
    PHP also covert output to XML,JSON,text,xhtml etc.,
    PHP also support to taking other services (LDAP,IMAP,HTTP,NNTP,POP3.COM (on Window) etc).
    PHP has extremely useful text processing features (Regexp)
    PHP features will continue....

    What it can do?

    There are three main areas where PHP scripts are used

    1. Server side scripting
    2. Command Line Scripting
    3. Desktop Applications


    Server side Scripting:

    You need three things to make this work
    1. Parser (Server module or CGI)
    2. Server
    3. Browser.

    These three things very important to run php script. Server connected with PHP parser. Then only its work in browser. We will see how to install these things?

    Command line Scripting:

    PHP can also be run as a command line script like c, c++, java, etc.

    You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows).

    Real command-line programs use arguments. just like C and other similar languages, you can use argv and argc for this purpose.






    PHP History (From Php.net)

    PHP/FI:
    PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'.
    Its Stands for
    Personal Home Page / Forms Interpreter.

    PHP/FI 2.0:

    PHP/FI 2.0 was officially released only in November 1997, after spending most of its life in beta releases.the second write-up of the C implementation, had a cult of several thousand users around the world (estimated), with approximately 50,000 domains reporting as having it installed, accounting for about 1% of the domains on the Internet

    PHP 3.0:

    PHP 3.0 was the first version that closely resembles PHP as we know it today. It was created by Andi Gutmans and Zeev Suraski in 1997 as a complete rewrite, after they found PHP/FI 2.0 severely underpowered for developing an eCommerce application they were working on for a University project. In an effort to cooperate and start building upon PHP/FI's existing user-base, Andi, Rasmus and Zeev decided to cooperate and announce PHP 3.0 as the official successor of PHP/FI 2.0.

    By the end of 1998, PHP grew to an install base of tens of thousands of users (estimated) and hundreds of thousands of Web sites reporting it installed. At its peak, PHP 3.0 was installed on approximately 10% of the Web servers on the Internet.

    PHP 4:

    By the winter of 1998, shortly after PHP 3.0 was officially released, Andi Gutmans and Zeev Suraski had begun working on a rewrite of PHP's core. The design goals were to improve performance of complex applications, and improve the modularity of PHP's code base. Such applications were made possible by PHP 3.0's new features and support for a wide variety of third party databases and APIs, but PHP 3.0 was not designed to handle such complex applications efficiently.

    The new engine, dubbed 'Zend Engine' (comprised of their first names, Zeev and Andi), met these design goals successfully, and was first introduced in mid 1999. PHP 4.0, based on this engine, and coupled with a wide range of additional new features, was officially released in May 2000, almost two years after its predecessor, PHP 3.0. In addition to the highly improved performance of this version, PHP 4.0 included other key features such as support for many more Web servers, HTTP sessions, output buffering, more secure ways of handling user input and several new language constructs.

    Today, PHP is being used by hundreds of thousands of developers (estimated), and several million sites report as having it installed, which accounts for over 20% of the domains on the Internet.

    PHP 5

    PHP 5 was released in July 2004 after long development and several pre-releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model and dozens of other new features.


    PHP Basic


    What is PHP?


    PHP stands for PHP:Hypertext Processor.
    PHP is a Scripting language that is defined for web development.
    Its very easy to use create Dynamic pages.
    Its easy to learn ( Its Syntax draws upon C , Java , Perl ).
    PHP is server side scripting language. Its parsed and interpreted in server side of a application result sent to browser

    Difference between server side and client side scripting?

    Client Side scripting:

    1. Client side its user's end experience ( You can not impose which OS should use etc)
    2. Client side script executed by user
    3. Its Browser dependent ( Some CSS will change for each browser )
    4. Scripting code visible to user and not secure
    5. Client side mainly uses for validation

    Server side scripting:
    1. You can define all those things ( Like OS,Server,DB etc)
    2. Script parsed and interrupted by server.
    3. Its browser independent
    4. Script is secure
    5. Connecting with database and used for creating dynamic pages