phpPhrasebook
[ class tree: phpPhrasebook ] [ index: phpPhrasebook ] [ all elements ]

Class: PhrasebookSql

Source Location: Program_Root/src/PhrasebookSql.php

Class Overview

Phrasebook
   |
   --PhrasebookSql

Implements the Phrasebook pattern for SQL statements


Author(s):

Methods


Inherited Variables

Inherited Methods

Class: Phrasebook

Phrasebook::Phrasebook()
Constructor for Phrasebook class.
Phrasebook::getDictionaryName()
Returns the name of the dictionary currently in use
Phrasebook::getPhrase()
Returns the phrase from the dictionary and will substitute variables when appropriate.
Phrasebook::getRemoveNewLines()
Returns the value of the RemoveNewLines setting
Phrasebook::load()
Loads the dictionary from the xml file into memory.
Phrasebook::setDictionaryName()
Registers the name of the dictionary to use next time the load function is called.
Phrasebook::setFileName()
Registers the name of the XML phrasebook file to use next time the load function is called.
Phrasebook::setRemoveNewLines()
Sets the value of the RemoveNewLines setting.

Class Details

[line 37]
Implements the Phrasebook pattern for SQL statements

This class implements the phrasebook pattern, as documented by Yonat Sharon and Rani Pinchuk in their paper, The Phrasebook Pattern available at http://jerry.cs.uiuc.edu/~plop/plop2k/proceedings/Pinchuk/Pinchuk.pdf. It uses similar calls and XML document format to Rani Pinchuk's Class::Phrasebook module for Perl.




Tags:

see:  phpPhrasebook
author:  Andrew Barilla <abarilla@users.sourceforge.net>


[ Top ]


Class Methods


constructor PhrasebookSql [line 54]

PhrasebookSql PhrasebookSql( string $a_stFileName)

Constructor for PhrasebookSql class.



Parameters:

string   $a_stFileName   a_stFileName The filename of the xml phrasebook document to read.

[ Top ]

method getDoMysqlEscapeString [line 228]

boolean getDoMysqlEscapeString( )

Returns the current value of the DoMysqlEscapeString setting



Tags:

return:  The value of the DoMysqlEscapeString setting
see:  PhrasebookSql::setDoMysqlEscapeString()


[ Top ]

method getEscapedQuote [line 258]

string getEscapedQuote( )

Returns the current value of the EscapedQuote setting



Tags:

return:  The value of the EscapedQuote setting
see:  PhrasebookSql::setEscapedQuote()


[ Top ]

method getPhrase [line 102]

string getPhrase( string $a_stName, [array $a_astValues = array()])

Returns the phrase from the dictionary and will substitute variables when appropriate.

One major difference between PhrasebookSql and the standard Phrasebook is that the PhrasebookSql class will remove lines from the SET part of the UPDATE method if those variables are not used. This results in the ability to define only one update statement but only updating some of the fields.

For example if the following statement is defined in the dictionary:

UPDATE my_table
SET field1 = $field1,
    field2 = '$field2',
    field3 = $field3
WHERE field4 = $field4

And you only pass the array ("field1"=>"123", "field4"=>"456"), the following statement will be produced:

UPDATE my_table
SET field1 = 123
WHERE field4 = 456




Tags:

return:  The phrase with variables replaced if appropriate


Overrides Phrasebook::getPhrase() (Returns the phrase from the dictionary and will substitute variables when appropriate.)

Parameters:

string   $a_stName   a_stName The key of the phrase to return
array   $a_astValues   a_astValues Array of strings to replace variables in the phrase with

[ Top ]

method getUseIsNull [line 199]

boolean getUseIsNull( )

Returns the current value of the UseIsNull setting



Tags:

return:  The value of the UseIsNull setting


[ Top ]

method setDoMysqlEscapeString [line 244]

void setDoMysqlEscapeString( boolean $a_boDoMysqlEscapeString)

Registers the value of the DoMysqlEscapeString.

When true, getPhrase will replace variables in the phrase that are surrounded by quotes to be run through the mysql_escape_string function. When false, the value of EscapedQuote will be used instead.




Parameters:

boolean   $a_boDoMysqlEscapeString   a_boDoMysqlEscapeString The value of the new DoMysqlEscapeString setting

[ Top ]

method setEscapedQuote [line 273]

void setEscapedQuote( string $a_stEscapedQuote)

Registers the value of the string to use to replace single quotes (') with when variables are surrounded by quotes in the phrase.

This defaults to two single quotes ('')




Parameters:

string   $a_stEscapedQuote   a_stEscapedQuote The value of the quotes to use

[ Top ]

method setUseIsNull [line 214]

void setUseIsNull( boolean $a_boUseIsNull)

Registers the value of the UseIsNull setting.

When true, getPhrase will change the text '= NULL' with 'is NULL'. When false, no changes to the phrase will occur.




Parameters:

boolean   $a_boUseIsNull   a_boUseIsNull The value of the new UseIsNull setting

[ Top ]


Documentation generated on Fri, 25 Jul 2003 23:23:40 -0400 by phpDocumentor 1.2.1