EAV model for magento

EAV模型代 表Entity-Attribute-Value,最早用于医学用途,医生在就诊时需要记录很多病人的参数,如体温,年龄,过敏药等情况,而这些参数并不 是每个病人都需要记录的。

由于商品的多样性,用EAV表来描述商品的各种属性也很合适。老牌电子商务应用oscommerce的表设计(为了简洁,我将商品属性名和属性值的 关系表略去):

Posted in PHP, Programming | 1 Comment

如何做好一个垂直搜索引擎

本文先引用几句话:
1.“确解用户之意,切返用户之需。”
2.“门户网站都想着是怎样省钱,而不是怎样花钱来买技术。”
3.“搜索引擎不是人人都能做的领域,进入的门槛比较高。”
4.“只是优秀还不够,最好的方式是将一件事情做到极致。”(google十大真理)
5.“做搜索引擎需要专注” “对于一项排到第四的业务,门户很难做到专注。”
6.“用户无法描述道他要找什么,除非让他看到想找的东西。”
7. “所谓楔形,其实就是个倒三角,倒三角的尖端部分代表搜索技术,中部是基于技术的产品应用平台,最上端是对整个搜索引擎用户人群文化的认识和理解,以及现代公司竞争最关键也最捉摸不定的所谓品牌。” “楔形”蕴涵的另一个意义是:楔子要打到墙里,尖端是否锐利很重要,但楔子的破坏性有多强,究竟能在墙面挤压出多大的空间,其中端、后端的沉稳与厚重才是关键。

搜索引擎的技术和理念都是需要时间和经验的积累的,更是需要长期不断的完善进步的,绝对不要认为可以一蹴而就,要达到一个相对成熟领先的搜索引擎从开始到领先的周期一般需要是四年。着急不得。原因是因为搜索引擎太复杂,而且“用户无法描述他要找什么,除非让他看到想找的东西。” 一切都需要摸索,尝试,问题需要一个一个解决,用户的需要得一点点的挖掘。

搜索引擎是一个产品,给用户提供服务的产品,需要长期的不断的改进升级调整才能持续不断的提用户体验,需要满足用户不断增长并且变化的需求、需要不断适应网络的变化。这是因为网络环境是不断变化的、网民的需求也是不断变化的。千万不要把搜索当成项目来做,做完了撂那让用户去用那你肯定没戏。在搜索引擎领域是讲体验的、新的引擎如果用户体验一旦整体上有领先一年以上的差距并且持续2年,那前期的领先者的优势就荡然无存,因为搜索引擎的用户转移成本相对而言是比较低的而且口碑是最佳的传播方式。如果一个搜索引擎不能持续不断的技术创新理念创新,那对于这个搜索引擎来说就等于死亡。我们一般形容搜索引擎的领先是以时间计算的。比如:中搜离百度整体差距

Posted in Search Engine | Tagged | Leave a comment

中文分词和TF-IDF

Posted in Search Engine | Tagged | Leave a comment

Top 10 Common Web Developer Questions on PHP

As a web developer begins to delve into more complex development tasks, PHP is often their chosen language of choice. We’ve put together a list of the top 10 questions asked about the PHP programming language to get you started!

What is PHP?

PHP is a recursive acronym for “PHP: Hypertext Preprocessor”. PHP is a widely-used general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Much more info can be found at PHP.net.

Are there online documentation and tutorials that can help me learn PHP?

The manual is on-line here and is also available in other languages and downloadable versions.

For a beginner’s tutorial on PHP, check out this Zend.com tutorial.

Can I run PHP locally on my PC?

Yes, but note that in addition to PHP you will need a web server running on your PC, too. A very convenient and effective way to do this is to download and install Apachefriends.org’s XAMPP, which is an open-source program which will install PHP, Apache web server, MySQL DBMS, and phpMyAdmin onto your PC.

How do you upload images (or other files) using PHP?

We have put together a great tutorial with useful information and example code on this subject.

How can I create a CMS (Content Management System) with PHP?

This is not a trivial project (unless done very poorly and with little to no consideration for security). Consider using one of the many open-source CMS’s which are available. OpenSourceCMS has lots of info on some of the many choices.

I get an error at line number X when I run my PHP script, but I don’t see any problem on that line.

The line number in a PHP parse error message is the line where PHP “got too confused and gave up,” but it’s not necessarily the line where the root cause of the problem occurred. When you get such a message start looking at that line, then start working your way back through the code for various syntax errors (missing “;”, unbalanced brackets or quotes, etc.) It is worth using an editor with PHP syntax color-coding to help you see some of these errors.

My script isn’t working right, but I can’t figure out why.

Learn to code defensively. Do not assume variables are set the way you think they should be; instead check their values before proceeding using functions like isset() and empty(). Learn to use PHP’s error-handling functions.

How can I ask a PHP question in a forum like WebDeveloper.com or PHPBuilder.com and get it answered?

  1. Search. Click on search at the top of the forum and enter your term; the odds are someone will already have asked your question.
  2. Describe. Tell forum members what it should do, how it is to do it and what’s wrong if you’re getting an error. If you’re unsure how to go about something then tell them what it should do and what you have already tried, this provides members with more info about what will and won’t work.
  3. Use the forum’s built in [php] tags around any and all coded sections (HTML as well as PHP). Your code will then be easier to read allowing forum members to be more accurate in their responses.
  4. Indent. I can’t specify this enough, but often the problem could be a simple matter of a missing brace(“{” or “}”); this is more common than you think.
  5. Ask a question. If you just give us information, no matter how accurate, unless forum members know what you want they cannot help you.
  6. If you have a script from a pre-made source, ask the author, they will properly know more about it than forum members.
  7. Cut down. Try to post only the relevant lines unless forum members ask for more. It ensures we will not be put off (and considering that forum members do this for free that’s not the result you want) and can reply quicker.

How can I use PHP to create login-controlled web pages?

This is usually done by using PHP sessions in conjunction with a database. The database contains login information which is used to verify the user’s login. Upon successful login, a session variable can be set. Controlled pages can then first check to see if this session variable exists and is properly set, and if not then redirect the user to the login page. Here is one article of many on the web on this subject.

How do I send emails with PHP?

Simply put, by using the mail() function. For more info, check out this article by Web Developer forum member Bokeh.

Posted in PHP, Programming | 1 Comment

PEAR PHP_CodeSniffer: End of line character is invalid; expected “\n” but found “\r\n”

The Issue:

I have another ERROR discovered by PEAR PHP_CodeSniffer, http://pear.php.net/package/PHP_CodeSniffer:
End of line character is invalid; expected “\n” but found “\r\n”

And this ERROR is only occurring at the very first line, at , in my PHP code.

The Sollution:

For new files, you can change the default line delimiter to Unix style, such as in Eclipse, you can,
Window –>

Posted in PHP, Programming | Tagged , , | Leave a comment

How to checking if PEAR works after installation

Verifying command line tool

Both pear and pecl tools should be available everywhere on command line. For that to work, pear’s binary (bin) directory should be in your PATH variable.

To verify it works, simply type pear. A list of commands should be shown:

$

Posted in MISC, PHP, Programming | Tagged | Leave a comment

PEAR Installation issue: phar “C:\php\PEAR\go-pear.phar” does not have a signature Warning

The issue:

I want to install PEAR manager for PHP 5.3.2 with apache on Windows, while run go_pear.bat

Posted in MISC, PHP, Programming | Tagged , | Leave a comment

PHP – PEAR installation get warning: date(): It is not safe to rely on the system’s timezone settings.

The Issue:

While I am install the PEAR for PHP 5.3.2 version with display_errors settings on, I get following error,

===========================================================
Warning: date(): It is not safe to rely on the system’s timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this

Posted in PHP | Tagged , , | Leave a comment

在活动目录中如何实现组的嵌套?

组帐户
Posted in Security, Windows | Tagged , , , | Leave a comment

How to installing PHPUnit 3.4

PHPUnit 3.4 requires PHP 5.1.4 (or later) but PHP 5.3.2 (or later) is highly recommended. It should be installed using the PEAR Installer. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0.

The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment. Furthermore, a component that PHPUnit depends upon is hosted on the Symfony Components PEAR channel (pear.symfony-project.com).

pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com

This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:

pear install phpunit/PHPUnit

After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually /usr/lib/php/PHPUnit.

Although using the PEAR Installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:

  1. Download a release archive from http://pear.phpunit.de/get/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  2. Prepare the phpunit script:

    1. Rename the phpunit.php script to phpunit.

    2. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).

    3. Copy it to a directory that is in your path and make it executable (chmod +x phpunit).

  3. Prepare the PHPUnit/Util/PHP.php script:

    1. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).

Posted in PHP | Tagged , , | Leave a comment