I missed the original post - sounds like homework to me

  ----- Original Message ----- 
  From: Tippus Tailus 
  To: [email protected] 
  Sent: Thursday, October 19, 2006 4:31 AM
  Subject: [php_mysql] Re: Query.... in PHP and MySQL


  --- In [email protected], Parag <[EMAIL PROTECTED]> wrote:
  >
  > Hi,
  > 
  > I am having some following queries
  > 
  > 1. What are the modifiers in Smarty in PHP ?

  No idea. Hopefully, someone else can answer.

  > 2. What is differenece between Primary Key and Unique Key if we
  make Unique key as Not Null ?

  Very good question. Superficially, a PRIMARY KEY is UNIQUE KEY and NOT
  NULL. However, some storage engines, such as InnoDB, may use an
  internal numeric primary if no PRIMARY KEY has been defined. For other
  storage engines, such as MyISAM, it doesn't make much difference.

  If your schema is normalized then your tables should have primary
  keys. Otherwise, this distinction will make a bad schema worse because
  it will further increase storage requirements, decrease row retrieval
  throughput and decrease cache coherency.

  In the case of a decomposed relationship between two tables, defining
  a composite PRIMARY KEY may be beneficial:

  CREATE TABLE `actor` (
  `actor__id` INT UNSIGNED PRIMARY KEY,
  `actor__dob` DATE,
  `actor__name` VARCHAR(64) NOT NULL
  ) ENGINE=INNODB;

  CREATE TABLE `film` (
  `film__id` INT UNSIGNED PRIMARY KEY,
  `film__name` VARCHAR(250) NOT NULL
  ) ENGINE=INNODB;

  CREATE TABLE `role` (
  `film__id` INT UNSIGNED NOT NULL,
  `actor__id` INT UNSIGNED NOT NULL,
  `role__character` VARCHAR(64) NOT NULL
  ) ENGINE=INNODB;

  ALTER TABLE `role` ADD PRIMARY KEY (`film__id`,`actor__id`);

  > 3. What is Versioning ? What Freeware or Shareware Softwares
  used for Versioning ?

  Versioning in databases is different to versioning in software such as
  CVS [Concurrent Versions System]. When you have concurrent
  transactions, it is very useful for each session to see the state of
  the database as is was when a transaction began. This requires holding
  old versions of rows until transactions commit or rollback.

  > 4. What is PHP - Documentor ? is it supported in PHP 4.x version ?

  No idea.

  > 5. What is funda of callback function and in what situation we
  use call back function in PHP and Javascript ?

  Callbacks in programming languages are used when you're working at a
  level below object orientation. It allows a specified routine to be
  called from a generic library. Examples include sorting and
  enumeration. In the case of sorting, you may a library routine, such
  as the POSIX qsort(...) which is very efficient and may be optimized
  for particular hardware. This library function can call the routine of
  your choice allowing the comparison of two arbitrary pieces of data.
  This would allow you to sort numbers, names, pictures and colors to
  your precise requirements.

  A programming callback gives you precision and speed. It allows you to
  draw upon the expertise embodied in libraries. In general, callbacks,
  trampolines, virtual methods and enumeration is heavy mathematical and
  programming theory. Investigate enumeration in SmallTalk for more
  information.

  Callbacks in JavaScript are used for AJAX trickery and are generally
  techniques for making hits on a web server to fetch new information.

  Firstly, any reference you've seen in PHP documentation about
  callbacks is completely unrelated to callbacks in AJAX. Secondly,
  defer these techniques until you've got a working application. It is
  quite simple to retro-code these improvements. To consider them in
  version 1 complicates your project and risks its entire failure.

  > 6. what is use of mysqli ? is it faster than normal mysql ?
  > how it increases speed of query when we use mysqli -
  extension than normal mysql functions available in php? (As we r using
  extension but i think there will same mysql functions used )

  MySQL Server 5.0 allows the use of stored procedures. Stored
  procedures may return multiple result sets. In PHP, mysqli_* functions
  handle multiple result sets mysql_* functions don't. If you want to
  use stored procedures effectively then you'll have to use mysqli_* .

  > 7. what should be done if there r more hits to mysql server as
  because of that it is delaying transcations processing ? what can be
  done to stream line this ?

  That's a very good question. You can configure your webserver to
  reduce the maximum number of concurrent connections and vastly
  increase the TCP listen buffer so that connections are not refused.
  You'll probably want to change settings anyhow. For example, Apache's
  default number of maximum connections is 150. MySQL Server 5.0's
  default number of maximum connections is 100. This is one reason that
  relatively busy websites occasionally display warnings about
  connection problems.

  > 8. when we give request to particular page - (we r using session)
  how server understand some specific value is to be displayed for
  particular session ? I want to know how it internally works (when we
  send request from browser- client to server) ? (any information sent
  like session id or something like that ?
  >
  > 9. how the hackers generally logs in remote site then ? i want to
  log in remote site which is not mine - how to find what cookies and
  session variables are created ?

  There are a variety of methods to implement sessions. I'm most
  familiar with writing my own in Perl and I haven't done PHP sessions
  for about five years.

  Popular methods include adding a session= parameter or suchlike to
  Method GET URLs and setting cookies. Not everyone want to share
  cookies and this is understandable because this facility is widely
  used by advertisers to abuse privacy. If you want to see this in
  action then enable the most paranoid cookie confirmation settings in
  your web browser. Firefox is good for setting appropriate security
  levels and displaying collected cookies.

  Method GET parameters also have weaknesses. For example, if a URL with
  a live session is shared between users then the session (and account)
  can be hi-jacked. Thankfully, there are functions and libraries which
  allow URLs to be selectively re-written to include session information
  as a Method GET parameter in the event that a cookie doesn't work.

  > 10. how index internally works ?
  > for ex. when searches like 
  > - select * from employee where name like '%par' - i want to
  compare first 3 characters of field
  > - select * from employee where name like 'par%' - i want to
  compare last 3 characters of field
  > which query is will take more time if i done indexing on name
  field - because i am comparing first 3 and last 3 characters

  If we use the following table and index as an example:

  CREATE TABLE `user` (
  `user__id` INT UNSIGNED PRIMARY KEY,
  `user__name_title` CHAR(8),
  `user__name_first` CHAR(32),
  `user__name_middle` CHAR(32),
  `user__name_last` CHAR(32),
  `user__name_suffix` CHAR(16)
  ) ENGINE=MYISAM;

  ALTER TABLE ADD INDEX `name`
  (`user__name_last`,`user__name_first`,`user__name_middle`);

  Then we implicitly get three indexes:

  (`user__name_last`,`user__name_first`,`user__name_middle`);
  (`user__name_last`,`user__name_first`);
  (`user__name_last`);

  So, we can efficiently search last name only; first name and last
  name; and first, middle and last name together.

  We can also efficiently perform the following:

  SELECT ... WHERE `user__name_last` LIKE 'Smith%';

  However, it doesn't help any other pattern or subset of columns. In
  these cases, the database will perform a full table scan unless you
  create additional indexes. For small quantities of data, it doesn't
  matter. For larger amounts of data, you can find problematic queries
  in the slow query log.

  Finally, UNIQUE doesn't apply to NULL. Try to avoid indexes on NULL
  values by normalizing.

  > 11. what different types of indexes available in mysql ? what r
  there use and internal working ?

  There are hash indexes. These are useful if you don't want to compare
  values or select a range of values. These are ideal for primary keys.

  There are B-trees. These are useful for finding alphanumeric prefixes
  or numeric ranges.

  There are T-trees. These are useful in in-memory databases, such as
  MySQL NDB Cluster, where the access speed of memory is significantly
  faster than disk.

  There are R-trees, which are two dimensional indexes useful for
  geographic data.

  There are probably other indexes. Different storage engines support a
  different subset of indexes.

  > 12. I want to submit page not using <form> tag -
  > how can i decide which method to choose - fsock / curl /
  snoopy class - or is there any other method than (Except javascript ).

  You may be lacking abstraction here. When you're editing source files,
  you've probably got a jumble of CSS, JavaScript, HTML, PHP and SQL.
  Don't do this. Put your CSS and JavaScript in separate files. Put your
  SQL queries in separate files. Put your application logic in separate
  files. Your HTML should have a minimal amount of PHP - just enough to
  reference your application logic, which in turn references your SQL
  routines. When the processed HTML is sent to a client, it collates the
  references to the CSS and JavaScript as appropriate.

  Your JavaScript runs on the client and your PHP runs on the server.
  When you abstract style, HTML, application and SQL then the separation
  is more defined. When you've incorrectly got everything in one file
  then it encourages woolly thinking - such as having CURL (in PHP on
  the server) submitting data like JavaScript (on the client).

  If you want to do DHTML, DOM and AJAX trickery then you are strongly
  advised to first separate your CSS, JavaScript, HTML, PHP and SQL. The
  current state is not your fault. The structure of PHP, ASP and similar
  languages encourages this mess. To fix it, try the following:

  <Script Language="JavaScript" Src="index.js"></JavaScript>
  <?php
  include 'library/app.php';
  include 'library/db.php';
  ?>

  > 13. when we create more than one fields how mysql server decides
  about which index to use for sorting records ?

  A suitable composite index will be used if it is present.
  Additionally, the cardinality of indexes will influence the order of
  retrieval from tables.

  > 14. What is use of CURL ?

  CURL allows applications to initiate network connections using a
  variety of protocols. This facility is ideal sourcing and submitting
  data to third parties, including third party credit card gateways,
  newsfeeds, weather reports, remote server status monitoring,
  authentication services, search services and abstraction within your
  application.

  The latter is particularly useful. For example, if you want to write
  an application which works on web browsers (HTML), mobile telephones
  (WAP) and desktops (XML) then you can write the core of your
  application as a web service and then provide skinned output for each
  interface.

  For example, a web service for searching may output the following:

  <SearchResultSet>
  <SearchResult Res="00012345" Name="Fun With PHP">
  <SearchResult Res="00012346" Name="Fun With MySQL">
  </SearchResultSet>

  You then write PHP which uses CURL to obtain this data and then output
  the following HTML:

  <OL>
  <LI><A HRef="?action=view-res&amp;res=00012345">Fun With PHP</A>
  <LI><A HRef="?action=view-res&amp;res=00012346">Fun With MySQL</A>
  </OL>

  The output for WAP may be completely different. For example, the WAP
  output may have significantly less style.

  The alternative to web services is a technique known as screen
  scraping. This is vastly less preferable and still requires facilities
  such as CURL.

  > Please let me know if u know these answers of any questions.
  > 
  > Quick Reply is definatly Appreciated
  > 
  > Regards,
  > 
  > Parag
  > 
  > 
  > Rgds, 
  > 
  > Parag Bhavsar

  Tippus Tailus



   

[Non-text portions of this message have been removed]



The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php_mysql/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to