PHP Classes

File: README

Recommend this page to a friend!
  Classes of markitos  >  cmysql_mset  >  README  >  Download  
File: README
Role: ???
Content type: text/plain
Description: Readme File
Class: cmysql_mset
Author: By
Last change:
Date: 21 years ago
Size: 4,668 bytes
 

Contents

Class file image Download
Clase CMySQL_MSet |[ mArKitos ]| '00
------------------------------------ 

|[Properties description ]|

- DB_Name   = Database name
- DB_User   = User name for MySQL conection
- DB_Pass   = Password for MySQL access
- DB_Host   = MySQL host server name
- DB_Link   = Description of MySQL link
- CM_TRUE   = Boleanean value [1]
- CM_FALSE  = Boleanean value [0]


#:............................................:#
#: All properties are private from the class  :#
#:............................................:#

|[ Methods description ]|

- CMySQL_MSet

Method constructor. Sets the properties for the conection data

- OpenConnection

Opening method for conection with MySQL server. Stores the descriptor of link in
the DB_Link in case it achieves to connect and returns 1.
On the contrary it returns 0 [CM_FALSE]

- CloseConnection

Method for closing the conection with MySQL server. Closes the conection which is
established with the DB_Link descriptor.

- ExecSQL

Execution method for a SQL sentence which is passed on to us as parameter.
Returns the results of the query in case it succeeds or 0 [CM_FALSE].

- SearchIn

Search method. We are sent the parameters of the name of the table we are searching for, as well
as its field, the pattern and a flag that indicates if the search has to be a complete pattern or
any other occurency with the pattern. The table has to be a valid table of the database and be part of
the DB_Name property.
The table has to include an auto_increment index field with tne name id, because in case of success we
will return a matrix whith the idīs of the registers where the search succeeded. The syntax of the call is:

    $Array = SearchIn ("Table_Name", "Field", "Pattern", "Full");

The 'Full' parameter has to be 1 in order to make the search a pattern complete or 0 for it to
be of any other occurency with the pattern.
Also, we can make the search not to be limited to just one field. For that, we only need to specify by
making a call to the method.

    $Array = SearchIn ("Table", "Field-1, Field-2, Field-N", "Pattern", "Full");

Remember that we can make the search for any valid field name in the database.
If the search shouldnīt have success it will return 0 [CM_FALSE]. In this way we can see how many registers
matches with our pattern.

	if (($Register_Number = count($Array)) < 1){
	    #: No register was found
	} else {
	    #: In the variable $Register_Number we have a
	    #: entire with the number of registers where the
	    #: search was successful.
	}

### All searches for this method are not case sensitive. For that we use SearchAdv.###

- SearchAdv

Advanced search method. This method is similar to the above mentioned, except in case it has some
advantages such as being able to make a case sensitive search and additional clauses.
The syntax for the call of this method is:

    $Array = SearchAdv ("Table", "Field", "Pattern", "Full", "CaseSensitive", "Clause", "SQL");

, where the 4 first parameters correspond to the 'SearchIn' method and the following are, :

    - CaseSensitive = Could be 1 or 0. 1 to tell that the search is case sensitive, distinguishing the Upper 
				from Lower Case, or 0 so it doesnīt do it.
    - Clausulas     = Could be 1 or 0. 1 to tell if we are going to give additional clauses.
    - SQL           = It will be a string (or a variable which value it is) with the SQL sentence from the clause 
that we want to put in the search. An example of this case could be:

    $Sql_Clause = "WHERE id>='2' ORDER BY Field-2";
    $Array = SearchAdv ("Table", "Field-1", "Field-2", "Pattern", "1", "1", "1", "$Sql_Clause");

This will make a complete search with the 'Pattern' pattern in the table 'Table', in the fields 'Field-1, Field-2'.
The search will be case sensitive and we will also give the clause 'WHERE id>='2' ORDER BY Field-2'.
This method inserts the SQL code at the end of the SELECT sentence.

Together with the class, I attach a file with a few tests so that you can see how the class works.
They are simple examples but by viewing them you can see how to call the methods, as well as making some
tests.

############################### AUTHORS NOTE ####################################
For any comment or clarification please mailme: markitos@jazzfiesta.com
This class has no restriction and is for free use. Should you make any change,
tell me in order to improve.
###################################################################################


----------------------
|[ #: HappY CodiNG :#]|
      mArkitos '00
----------------------
For more information send a message to info at phpclasses dot org.