Niouzes

< Août 2018 >
Lu Ma Me Je Ve Sa Di
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Citation

Attention

The documentation is incomplete. The Vae Soli! team works hard to make it as exhaustive as possible with tons of useful examples and easy to understand explanations.

On top of that, we have decided to use our own tool to generate the documentation you read. This also takes time to fine-tune. Our goal is have better documentation, easier to read, easier to use, completely integrated with our site.

Even though NOT finalized, you can now link back to our documentation pages as we have decided once and for all about the structure of our documents and where they all reside on our server.

Thank you very much
The Vae Soli! team.

2018-08-20 à 07:03:02

Table Of Contents

  1. FOUNDATION (functions) (01/04/2015)
  2. LSAction (class) (01/04/2015)
  3. LSAddress (class) (01/04/2015)
  4. LSAdministrativeArea (class) (01/04/2015)
  5. LSApplication (class) (14/10/2013)
  6. LSArray (class) (14/10/2013)
  7. LSArticle (class) (18/02/2014)
  8. LSAssertion (class) (14/10/2013)
  9. LSAudience (class) (18/02/2014)
  10. AUTOLOAD (function) (21/04/2014)
  11. LSAutoReference (class) (14/10/2013)
  12. LSBag (class) (14/10/2013)
  13. LSBBCodes (class) (10/06/2014)
  14. LSBrowser (class) (14/10/2013)
  15. LSCache (class) (14/10/2013)
  16. LSCalculator (class) (14/10/2013)
  17. LSCalendar (class) (14/10/2013)
  18. LSCameraSnapshot (class) (14/10/2013)
  19. LSCitation (class) (14/10/2013)
  20. LSClass (class) (14/10/2013)
  21. LSCode (class) ()
  22. Colors (functions) (20/08/2018)
  23. LSContactForm (class) (14/10/2013)
  24. LSContainer (class) (14/10/2013)
  25. LSContents (class) (14/10/2013)
  26. LSContentsAccounts (class) (14/10/2013)
  27. LSContentsArticles (class) (14/10/2013)
  28. LSContentsAtomicClock (class) (14/10/2013)
  29. LSContentsBusinessCoordinates (class) (14/10/2013)
  30. LSContentsBusinessOff (class) (14/10/2013)
  31. LSContentsBusinessOpeningHours (class) (14/10/2013)
  32. LSContentsBreadcrumb (class) (14/10/2013)
  33. LSContentsCalendar (class) (14/10/2013)
  34. LSContentsCatalogue (class) (14/10/2013)
  35. LSContentsCharter (class) (18/02/2014)
  36. LSContentsCitation (class) (14/10/2013)
  37. LSContentsClock (class) (14/10/2013)
  38. LSContentsComments (class) (14/10/2013)
  39. LSContentsCookieUsage (class) (14/10/2013)
  40. LSContentsCountdown (class) (14/10/2013)
  41. LSContentsDatetime (class) (14/10/2013)
  42. LSContentsHeartbeat (class) (14/10/2013)
  43. LSContentsIFrame (class) (14/10/2013)
  44. LSContentsImageGallery (class) (14/10/2013)
  45. LSContentsLanguageSwitchers (class) (14/10/2013)
  46. LSContentsLegal (class) (18/02/2014)
  47. LSContentsMicronews (class) (14/10/2013)
  48. LSContentsMyAccount (class) (14/10/2013)
  49. LSContentsPaymentOptions (class) (14/10/2013)
  50. LSContentsPinboard (class) (14/10/2013)
  51. LSContentsRememberPassword (class) (14/10/2013)
  52. LSContentsRSS (class) (14/10/2013)
  53. LSContentsSiteManager (class) (14/10/2013)
  54. LSContentsSitemap (class) (14/10/2013)
  55. LSContentsShare (class) (14/10/2013)
  56. LSContentsStopwatch (class) (14/10/2013)
  57. LSContentsTagCloud (class) (14/10/2013)
  58. LSContentsTodosOnPage (class) (14/10/2013)
  59. LSContentsW3C (class) (14/10/2013)
  60. LSContentsWeather (class) (14/10/2013)
  61. LSControl (class) (14/10/2013)
  62. LSCreativeWork (class) (18/02/2014)
  63. LSCursor (class) (09/03/2015)
  64. LSCustomer (class) (14/10/2013)
  65. LSDataEnvironment (class) (14/10/2013)
  66. Dates (functions) (01/04/2015)
  67. LSDate (class) (14/10/2013)
  68. LSDictionary (class) (14/10/2013)
  69. LSDom, LSDomNode and LSXPath (class) (30/04/2014)
  70. LSErrors and LSError (classes) (14/10/2013)
  71. LSException (class) (16/10/2013)
  72. LSExplorer (class) (14/10/2013)
  73. LSFieldset (class) (14/10/2013)
  74. LSFile (class) (14/10/2013)
  75. LSFileProperties (class) (14/10/2013)
  76. Files (functions) (01/04/2015)
  77. Finance (functions) (01/04/2015)
  78. LSFootnotes (class) (22/02/2014)
  79. LSForm (class) (09/06/2014)
  80. LSFunction (class) (14/10/2013)
  81. LSGeorama (class) (24/10/2013)
  82. LSGeoramaVar (class) (24/10/2013)
  83. LSGlossary (class) (09/03/2015)
  84. LSGroup (class) (14/10/2013)
  85. HTML (functions) (01/04/2015)
  86. LSHttp (class) (14/10/2013)
  87. HTTP (functions) (01/04/2015)
  88. LSImageGallery (class) (14/10/2013)
  89. Images (functions) (01/04/2015)
  90. LSInput (class) (26/04/2014)
  91. IP (functions) (01/04/2015)
  92. LSIslandAbstract (14/10/2013)
  93. LSIslandFormAbstract (class) (14/10/2013)
  94. LSLabel (class) (14/10/2013)
  95. LSLanguageSwitchers (class) (14/10/2013)
  96. LSLatin (class) (14/10/2013)
  97. LSLegalPerson (class) (14/10/2013)
  98. LSLinkedList (class) (14/10/2013)
  99. LSList (class) (14/10/2013)
  100. Mails (functions) (01/04/2015)
  101. LSMap (class) (14/10/2013)
  102. Math (functions) (01/04/2015)
  103. LSMicronews (class) (18/02/2014)
  104. Miscellaneous (functions) (01/04/2015)
  105. LSModuleAbstract (class) (14/10/2013)
  106. LSNaturalPerson (class) (14/10/2013)
  107. LSNewsArticle (class) (18/02/2014)
  108. LSNote (class) (14/10/2013)
  109. LSMotherNature (class) (16/10/2013)
  110. LSPage (class) (18/02/2014)
  111. LSParameter (class) (14/10/2013)
  112. LSPaymentOptions (class) (14/10/2013)
  113. LSPeopleAudience (class) (18/02/2014)
  114. LSPerson (class) (14/10/2013)
  115. LSPlace (class) (18/02/2014)
  116. LSProperty (class) (14/10/2013)
  117. LSPublication (class) (14/10/2013)
  118. LSRequirement (class) (14/10/2013)
  119. LSReturn (class) (24/10/2013)
  120. LSRisk (class) (14/10/2013)
  121. LSSentanaiAbstract (14/10/2013)
  122. LSServiceMessage (class) (14/10/2013)
  123. LSSession (class) (14/10/2013)
  124. LSSiteManager (class) (14/10/2013)
  125. LSSitemap (class) (14/10/2013)
  126. LSSockets (class) (14/10/2013)
  127. LSSoftwareApplication (class) (18/02/2014)
  128. LSSource (class) (14/10/2013)
  129. Strings (functions) (31/07/2016)
  130. LSSupplier (class) (14/10/2013)
  131. System (functions) (01/04/2015)
  132. LSTag (class) (21/04/2014)
  133. LSTagCloud (class) (14/10/2013)
  134. LSTechArticle (class) (18/02/2014)
  135. LSThing (class) (18/02/2014)
  136. LSTimeline (class) (14/10/2013)
  137. LSTimer (class) (16/10/2013)
  138. LSTracer (class) (09/03/2015)
  139. LSUnitTesting (class) (14/10/2013)
  140. URL (functions) (01/04/2015)
  141. LSUser (class) (09/03/2015)
  142. LSUserMgr (class) (14/10/2013)
  143. LSVaesoli (class) (09/06/2014)
  144. LSVersion (class) (14/10/2013)
  145. LSWebSite (class) (14/10/2013)
  146. LSWidget (class) (14/10/2013)
  147. LSWireTransferForm (class) (14/10/2013)
  148. LSXMLSitemap (class) (14/10/2013)
  149. XML (functions) (01/04/2015)

LSCursor.class.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 09-03-2015 09:36:34 (DD-MM-YYYY HH:mm:SS). This documentation is built with Vae Soli! functions and classes!

File Properties

C:\websites\vaesoli.org\www\httpdocs/vaesoli/include/LSCursor.class.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSCursor.class.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include339472 bytes03/08/2013 23:27:5130/01/2015 09:22:3930/01/2015 09:22:39

Compliance

Assertions count: 172

Assertions successful: 172

Assertion failures: 0

Early Warning

LSCursor.class.php exceeds 51200 bytes. We suggest this file got broken down in smaller chunks!

LSCursor.class.php contains 6884 lines of code, which exceeds the suggested limit of 1024 lines. We suggest this file got broken down in smaller chunks!

Manifest Constants

LS_CURSOR_CLASS: Define "LS" Cursor (Pat Was Here)

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

Sources required

LSInput.class.inc: Manifest constants defined for input support

LSV.errors.inc: Error codes

LSStrings.functions.php: String functions

LSFiles.functions.php: File functions

LSUnitTesting.class.php: Vae Soli! Unit Testing

LSDom.class.php: DOMDocument classes

Classes

LSCursorGeneric services for Vae Soli! databases. It can serve XML databases (full implementation) and SQLite databases (partial implementation)

Properties
NameVisibilityTypeDescription
$IsDebug public bool Indicates whether debugging information must be displayed when accessing the cursor (false by default)
$IsDirty public bool Indicates whether the cursor contains uncommited changes (false by default)
$IsLoaded public bool Determines if cursor is loaded not
$IsOpened public bool Determines if cursor is opened or not
$IsReadOnly public bool Indicates that the cursor is a readonly cursir or not (false by default)
$NoDataOnLoad public bool Indicates whether data must be fetched or not (true]/c] by default)
$NoInclusionOnLoad public bool Indicates that xinclude() should NOT be treated (valid for DATA_SOURCE_TYPE_XML cursors)
$WithCDATA public bool Indicates whether the filed must be saved in a CDATA structure (true by default (see __set))
$aErrors public array An array of cursor errors (Experimental error messages stack (should make it protected later)
$aEvents public array An array of events internally treated by the LSCursor class
$aMappings public array An array of field mappings
$aWorkareas public array An array of possible work areas
$iDetailCount public int Current subrecords count (e.g. Tel[1], Tel[2], ...)
$iFrom public int Starting record (not thoroughly tested though)
$iMaxReccount public int Maximum number of records (-1 by default, which indicates no max record)
$iReccount public int Current record count
$iRecno public int Current record number
$iTo public int Ending record (not thoroughly tested though)
$oDom public LSDom Internal DOM (valid for DATA_SOURCE_TYPE_XML cursors)
$oList public DOMNodeList If records found : the list resulting from the query (valid for DATA_SOURCE_TYPE_XML cursors)
$oNode public DOMNode The current node in oList (valid for DATA_SOURCE_TYPE_XML cursors)
$oXPath public LSXPath Internal XPath (valid for DATA_SOURCE_TYPE_XML cursors)
$szComment public string Database/table comment
$szDataSource public string Physical database/table file
$szDataSourceType public int Database type (XML type by default); types defined in LSInput.class.inc
$szFilter public string Active filter on database/table
$szName public string Name of the database/table
$szOrder public string Active order on database/table
$szOrderBy public string Active order on database/table
$szOrderDir public string Order direction (ascending or descending). ascending by default
$szTable public string Table we're working on (valid for DATA_SOURCE_TYPE_SQLITE3 cursors )
$xCargo public mixed Feel free to put whatever you like in there: this member if for you
$xHandle public mixed DB handle (valid for DATA_SOURCE_TYPE_SQLITE3 cursors )
Methods
  1. __construct(): Class constructor
  2. __destruct(): Class destructor
  3. __get(): Magic method. Called when trying to access a property which seems to be not accessible/not existing. No assertion found for __get() (0 - 0)
  4. __set(): Magic method. Called when trying to set a property which seems to be not accessible No assertion found for __set() (0 - 0)
  5. __toForm(): Renders an input control, either in "edit" or in "view" mode (default mode). No assertion found for __toForm() (0 - 0)
  6. Alias(): Determines whether the $szName alias exists No assertion found for Alias() (0 - 0)
  7. Append(): Adds a new record No assertion found for Append() (0 - 0)
  8. Average(): Calculates the average of a field No assertion found for Average() (0 - 0)
  9. BOF(): Determines if cursor is at beginning of file position No assertion found for BOF() (0 - 0)
  10. Change(): Switches the value of a logical field: 'true' becomes 'false' and vice versa No assertion found for Change() (0 - 0)
  11. ClearMappings(): Clears all defined mappings No assertion found for ClearMappings() (0 - 0)
  12. Close(): Closes the cursor/table No assertion found for Close() (0 - 0)
  13. Connect(): Connects to the database/data file (if the underlying database format requires such connection). No assertion found for Connect() (0 - 0)
  14. Create(): Creates the physical cursor file No assertion found for Create() (0 - 0)
  15. DebugMsg(): Displays a debug message
  16. Delete(): Soft deletes the current record (@active is set to 'no') No assertion found for Delete() (0 - 0)
  17. DeleteMapping(): Deletes a mapping No assertion found for DeleteMapping() (0 - 0)
  18. DetailCount(): Returns the number of sub-records found in a record No assertion found for DetailCount() (0 - 0)
  19. Dirty(): Determines if the database/table contains uncommitted records No assertion found for Dirty() (0 - 0)
  20. dtos(): Turns a DD/MM/YYYY date into a YYYYMMDD date No assertion found for dtos() (0 - 0)
  21. Eliminate(): Eliminates/Deletes a field of the current record. The field is removed physically = removed from the record. No assertion found for Eliminate() (0 - 0)
  22. EOF(): Determines if cursor is at end of file position No assertion found for EOF() (0 - 0)
  23. Field(): Returns the value of a field No assertion found for Field() (0 - 0)
  24. FileExists(): Determines if a file exists No assertion found for FileExists() (0 - 0)
  25. GetMappings(): Get all defined mappings No assertion found for GetMappings() (0 - 0)
  26. GetReccount(): Calculates the number of records in the current table
  27. GetXML(): Gets the whole XML of the DB (corresponding to all the records) No assertion found for GetXML() (0 - 0)
  28. Go(): Go to a specific record number No assertion found for Go() (0 - 0)
  29. GoBottom(): Go to the last record No assertion found for GoBottom() (0 - 0)
  30. GoTop(): Go to the first record No assertion found for GoTop() (0 - 0)
  31. Guid(): Returns a GUID (unique in time, unique in space) No assertion found for Guid() (0 - 0)
  32. Hours(): Keeps the 'HH' part of a 'HH:MM[:SS]' string No assertion found for Hours() (0 - 0)
  33. Index(): Index the cursor/table on a specific field (values MUST be unique) No assertion found for Index() (0 - 0)
  34. IsDeleted(): Determines if a record is soft deleted or not No assertion found for IsDeleted() (0 - 0)
  35. IsMapped(): Determines if a field has been mapped No assertion found for IsMapped() (0 - 0)
  36. IsOpen(): Determines if the cursor/table is open No assertion found for IsOpen() (0 - 0)
  37. IsTargetField(): Determines if a field is a target of a mapping No assertion found for IsTargetField() (0 - 0)
  38. LastErrorMsg(): Returns the last error message No assertion found for LastErrorMsg() (0 - 0)
  39. Map(): Maps a logical field to a physical field No assertion found for Map() (0 - 0)
  40. Max(): Determines the maximum value of a field No assertion found for Max() (0 - 0)
  41. Min(): Determines the minimum value of a field No assertion found for Min() (0 - 0)
  42. Minutes(): Keeps the 'MM' part of a 'HH:MM' string No assertion found for Minutes() (0 - 0)
  43. Now(): Formats the current time in YYYYMMDDHHmmSS No assertion found for Now() (0 - 0)
  44. Open(): Opens the cursor/table No assertion found for Open() (0 - 0)
  45. Recall(): Soft recalls the current record (@active is set to 'yes') No assertion found for Recall() (0 - 0)
  46. Reccount(): Returns the number of records found in the cursor (or table) No assertion found for Reccount() (0 - 0)
  47. Recno(): Returns the current record position No assertion found for Recno() (0 - 0)
  48. Record(): Returns the current record as XML No assertion found for Record() (0 - 0)
  49. RegisterEvent(): Register event No assertion found for RegisterEvent() (0 - 0)
  50. Remove(): Removes the current record (physically) No assertion found for Remove() (0 - 0)
  51. Replace(): Replaces the value of a field with a new value No assertion found for Replace() (0 - 0)
  52. Requery(): Requeries the cursor No assertion found for Requery() (0 - 0)
  53. Save(): Saves the cursor physically No assertion found for Save() (0 - 0)
  54. Scatter(): Copies data from the current record to a DOMNode object No assertion found for Scatter() (0 - 0)
  55. Search(): Searches a value in each record (search starts where the cursor pointer is positioned - update with GoTop() if needed) No assertion found for Search() (0 - 0)
  56. Seconds(): Keeps the 'SS' part of a 'HH:MM:SS' string No assertion found for Seconds() (0 - 0)
  57. Seek(): Seeks a value in a specific field (seek starts at where the cursor pointer is positioned - update with GoTop() if needed) No assertion found for Seek() (0 - 0)
  58. SeekIndex(): Seek a value by taking advantage of the $szIDXFile index file. No assertion found for SeekIndex() (0 - 0)
  59. Select(): Selects a fraction of the records of a given cursor No assertion found for Select() (0 - 0)
  60. SetFilter(): Applies a new filter on the data file No assertion found for SetFilter() (0 - 0)
  61. Skip(): Skips $n records No assertion found for Skip() (0 - 0)
  62. Sort(): Sorts the cursor on a given field No assertion found for Sort() (0 - 0)
  63. Stod(): Turns a YYYYMMDD[HHmmSS] date into a DD/MM/YYYY date No assertion found for Stod() (0 - 0)
  64. Stot(): Creates a time value (time()) from a YYYYMMDDHHmmSS string No assertion found for Stot() (0 - 0)
  65. Sum(): Calculates the sum of a field No assertion found for Sum() (0 - 0)
  66. Time(): Turns a YYYYMMDDHHmmSS date into a HH:mm[:SS] string No assertion found for Time() (0 - 0)
  67. Toggle(): Toggle a field (true to false and vice versa No assertion found for Toggle() (0 - 0)
  68. UserAgent(): Determines the User Agent of the visitor
  69. Value(): Returns the text value of the current record No assertion found for Value() (0 - 0)
  70. VisitorIP(): Determines the IP address of the visitor No assertion found for VisitorIP() (0 - 0)
__construct(): Class constructor

[ back to method list ]

Syntax

__construct( $szName,$szDataSource,$szDataSourceType,$szTable )

Parameters
NameTypeDescription
$szName string Name of the cursor
$szDataSource string Physical file name to be accessed
$szDataSourceType int Cursor type (DATA_SOURCE_TYPE_XML by default)
$szTable string Optional table. null by default
Parameters Warning

__construct() uses 4 parameters whereas the suggested limit is 3.

Return

(void)

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szFile  = FIL_Normalize( FIL_ResolveRoot( "/vaesoli/include/ut/uad.xml" ) );
$oCursor = new LSCursor( 'User Account Database',$szFile );

$oCursor->Open();

echo LSUnitTesting::assert( $oCursor->IsOpen()                              ,
                            'ASSERTION SUCCESSFUL: cursor successfully open',
                            'ASSERTION FAILURE: cannot open cursor'         ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Reccount() === 2                      ,
                            'ASSERTION SUCCESSFUL: count of records correct',
                            'ASSERTION FAILURE: incorrect count'            ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Recno() === 1                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );
$oCursor->Skip();
echo LSUnitTesting::assert( $oCursor->Recno() === 2                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );
$oCursor->Skip();
echo LSUnitTesting::assert( $oCursor->EOF()                                 ,
                            'ASSERTION SUCCESSFUL: end of file detected'    ,
                            'ASSERTION FAILURE: end of file NOT detected'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Close()                                   ,
                            'ASSERTION SUCCESSFUL: cursor closed successfully'  ,
                            'ASSERTION FAILURE: cannot close cursor'            ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Reccount() === -1                     ,
                            'ASSERTION SUCCESSFUL: count of records correct',
                            'ASSERTION FAILURE: incorrect count'            ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Recno() === -1                        ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: cursor successfully open

GuideAssert() ... ASSERTION SUCCESSFUL: count of records correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: end of file detected

GuideAssert() ... ASSERTION SUCCESSFUL: cursor closed successfully

GuideAssert() ... ASSERTION SUCCESSFUL: count of records correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

Unit Testing

8 assertions: 8 successful; 0 failed

__destruct(): Class destructor

[ back to method list ]

Syntax

__destruct()

Parameters

None

Return

(void)

Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

__get(): Magic method. Called when trying to access a property which seems to be not accessible/not existing.

[ back to method list ]

Syntax

__get( $szName )

Parameters
NameTypeDescription
$szName string Name of the property to look for. Used to return a field of the cursor
Return

(mixed) The value of the property/field that is accessed

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Replace( 'Name','John Doe' );
    echo '<p>',( $szName = $oCursor->Name ),'</p>';

    $oCursor->Save();

    echo LSUnitTesting::assert( $szName === 'John Doe'                                  ,
                                'ASSERTION SUCCESSFUL: property successfully retrieved' ,
                                'ASSERTION FAILURE: incorrect property value'           ,
                                'GuideAssert' );
    $oCursor->Close();
}

function setID()
{
    return ( strtolower( str_replace( array('{','}'),'',guid() ) ) );
}

John Doe

GuideAssert() ... ASSERTION SUCCESSFUL: property successfully retrieved

Unit Testing

1 assertions: 1 successful; 0 failed

__set(): Magic method. Called when trying to set a property which seems to be not accessible

[ back to method list ]

Syntax

__set( $szName,$xValue )

Parameters
NameTypeDescription
$szName string Name of the property to set. Used to replace a field of the cursor
$xValue mixed Value to set
Return

(bool) true if $szName has been replaced successfully; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    global $xDestructVar;
    $xDestructVar = 'Any Value';

    $oCursor->RegisterEvent( 'replace'  ,'UTEventSet' );
    $oCursor->RegisterEvent( 'save'     ,'UTEventSet' );
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Name = 'John Doe';

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'REPLACE'                        ,
                                'ASSERTION SUCCESSFUL: field replacement playback successful'   ,
                                'ASSERTION FAILURE: field replacement playback failure'         ,
                                'GuideAssert' );

    echo '<p>',( $szName  = $oCursor->Name ),'</p>';

    echo LSUnitTesting::assert( $szName === 'John Doe'                              ,
                                'ASSERTION SUCCESSFUL: property successfully set'   ,
                                'ASSERTION FAILURE: incorrect property value'       ,
                                'GuideAssert' );

    echo '<p>',( $szName2 = $oCursor->Field( 'Name') ),'</p>';

    echo LSUnitTesting::assert( $szName === $szName2                                                        ,
                                'ASSERTION SUCCESSFUL: direct property set and field() access equivalent'   ,
                                'ASSERTION FAILURE: unexpected distinct values'                             ,
                                'GuideAssert' );

    $oCursor->Save();

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'SAVE'               ,
                                'ASSERTION SUCCESSFUL: save playback successful'    ,
                                'ASSERTION FAILURE: save playback failure'          ,
                                'GuideAssert' );
    var_dump( $GLOBALS['xDestructVar'] );
    $oCursor->Close();
}

function UTEventSet( $oCursor,$szEvent )
{
    switch ( strtolower( $szEvent ) )
    {
        case 'save'     :
        case 'open'     :
        case 'close'    :
        case 'append'   :
        case 'replace'  :   $GLOBALS[ 'xDestructVar' ] = strtoupper( $szEvent );
                            break;
    }
}

GuideAssert() ... ASSERTION SUCCESSFUL: field replacement playback successful

John Doe

GuideAssert() ... ASSERTION SUCCESSFUL: property successfully set

John Doe

GuideAssert() ... ASSERTION SUCCESSFUL: direct property set and field() access equivalent

GuideAssert() ... ASSERTION SUCCESSFUL: save playback successful

string 'SAVE' (length=4)
Unit Testing

4 assertions: 4 successful; 0 failed

__toForm(): Renders an input control, either in "edit" or in "view" mode (default mode).

[ back to method list ]

Modified: 20/04/2014 08:50

Author

Syntax

__toForm( $aFields,$bWithData,$szLabelClass,$szTextboxClass,$szFormat )

Alias

ToForm()

Parameters
NameTypeDescription
$aFields array Array of fields to be considered when building the form. Optional. null by default.
$bWithData bool Includes the value of the fields in the generated code. Optional. null by default.
$szLabelClass string Class of the labels. Optional. null by default.
$szTextboxClass string Class of the textboxes. Optional. null by default.
$szFormat string Generation output format. Either 'html' or 'object' generates the full code of the form (the form is fully generated). Any other value generates the code that will generate the form.
Parameters Warning

__toForm() uses 5 parameters whereas the suggested limit is 3.

Return

(string) HTML code of a form that gathers all the fields of the first record of the cursor if $szFormat = 'html' or = 'object'. For any other value of $szFormat, the return value is the code that would be used to generate the form. Optional. null by default.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Create( 'whatever',$szFile );
$oCursor->Append( 'Item' );
$oCursor->Replace( 'Name/LName','Doe' );
$oCursor->Replace( 'Name/FName','John' );
$oCursor->Replace( 'Birthday','19591811' );
$oCursor->Replace( '@active',true );

$szForm = $oCursor->__toForm();

echo wordwrap( htmlentities( $szForm ) );

echo LSUnitTesting::assert( preg_match( '%<form.+>.+<fieldset>.+</fieldset>.+</form>%s',$szForm )   ,
                            'ASSERTION SUCCESSFUL: form successfully created'                       ,
                            'ASSERTION FAILURE: cannot create form from cursor'                     ,
                            'GuideAssert' );

$szForm = $oCursor->__toForm( null,false,null,null,'code');

echo $szForm;

echo LSUnitTesting::assert( preg_match( '%new +LSForm().+new +LSFieldset().+' .
                                        'new +LSInput(.+\'textbox\',\'txtLName\',\'txtLName\'.+)%s',$szForm )   ,
                            'ASSERTION SUCCESSFUL: form successfully created'                                   ,
                            'ASSERTION FAILURE: cannot create form from cursor'                                 ,
                            'GuideAssert' );

LSTag(UA=Wget/1.9+cvs-dev-200404081407)
<script type="text/javascript">
// <![CDATA[

//]]>
</script>

<form action="/guide.php" method="post">

<fieldset>
<legend> [ Automatic form ] </legend>
<label>LName:</label><input type="text"
value=""  name="LName" tabindex="1" 
/><label>FName:</label><input type="text"
value=""  name="FName" tabindex="2" 
/><label>Birthday:</label><input type="text"
value=""  name="Birthday" tabindex="3" 
/></fieldset>
</form>

GuideAssert() ... ASSERTION SUCCESSFUL: form successfully created

/* This code has been generated automatically by Vae Soli!
LSCursor::__toForm() at line 6788 on 09/03/2015 09:36:35 */

/*== [ Code for the form ] ==============================*/

$oForm = new LSForm();
$oFieldset = new LSFieldset();
/*---------------------------------------------*/
$txtLName = new LSInput( 'textbox','txtLName','txtLName' );
$lblLName = new LSLabel( 'LName' );
$lblLName->szFor = $txtLName;
$lblLName->szTooltip = $lblLName->AutoTooltip();
/*---------------------------------------------*/
$txtFName = new LSInput( 'textbox','txtFName','txtFName' );
$lblFName = new LSLabel( 'FName' );
$lblFName->szFor = $txtFName;
$lblFName->szTooltip = $lblFName->AutoTooltip();
/*---------------------------------------------*/
$txtBirthday = new LSInput( 'textbox','txtBirthday','txtBirthday' );
$lblBirthday = new LSLabel( 'Birthday' );
$lblBirthday->szFor = $txtBirthday;
$lblBirthday->szTooltip = $lblBirthday->AutoTooltip();
/*---------------------------------------------*/
$oFieldset->AddObject( array( $lblLName,$txtLName ) );
$oFieldset->AddObject( array( $lblFName,$txtFName ) );
$oFieldset->AddObject( array( $lblBirthday,$txtBirthday ) );
/*-------------------------------------------------------*/

$oForm->AddObject( $oFieldset );
echo $oForm;

/*== [ Update code ] ====================================*/
/*-- [ Retrieving vars ] --------------------------------*/
$txtLName = $_POST['txtLName'];
$txtFName = $_POST['txtFName'];
$txtBirthday = $_POST['txtBirthday'];


/*-- [ Saving in cursor] --------------------------------*/
$oCursor->Replace( 'Name/LName',$txtLName );
$oCursor->Replace( 'Name/FName',$txtFName );
$oCursor->Replace( 'Birthday',$txtBirthday );

GuideAssert() ... ASSERTION SUCCESSFUL: form successfully created

Unit Testing

2 assertions: 2 successful; 0 failed

Alias(): Determines whether the $szName alias exists

[ back to method list ]

Syntax

Alias( $szName )

Parameters
NameTypeDescription
$szName string The alias to look for
Return

(LSCursor) a cursor if $szName alias found; null if not.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor    = new LSCursor( 'temp',$szFile );
$oTemp      = $oCursor->Alias('temp');

echo LSUnitTesting::assert( $oTemp instanceof LSCursor          ,
                            'ASSERTION SUCCESSFUL: cursor found',
                            'ASSERTION FAILURE: cannot connect' ,
                            'GuideAssert' );

$oTemp      = $oCursor->Alias('unknown');

echo LSUnitTesting::assert( is_null( $oTemp )                                   ,
                            'ASSERTION SUCCESSFUL: cursor NOT found as expected',
                            'ASSERTION FAILURE: cursor found! Weird!'           ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: cursor found

GuideAssert() ... ASSERTION SUCCESSFUL: cursor NOT found as expected

Unit Testing

2 assertions: 2 successful; 0 failed

Append(): Adds a new record

[ back to method list ]

Syntax

Append( $szTag,$szField,$szValue,$bCDATA )

Alias

Insert()

Parameters
NameTypeDescription
$szTag string Name of the tag we would like to add (parent tag) (DATA_SOURCE_TYPE_XML)
$szField string Name of the field that must be inserted
$szValue string Value of the field to insert
$bCDATA bool Include in CDATA section? (DATA_SOURCE_TYPE_XML)
Parameters Warning

Append() uses 4 parameters whereas the suggested limit is 3.

Return

(bool) true if record successfully added; false otherwise.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';


if ( is_file( $szFile ) )
{
    FIL_Del( $szFile );
}

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Replace( '@id',SetID() );

    $iReccount1 = $oCursor->Reccount();

    for ( $i = 1; $i <=5; $i++ )
    {
        $oCursor->Append( 'Item' );
        $oCursor->Replace( '@id',SetID() );
    }

    $iReccount = $oCursor->Reccount();

    $oCursor->Save();

    echo LSUnitTesting::assert( $iReccount1 === 1                           ,
                                'ASSERTION SUCCESSFUL: Correct record count',
                                'ASSERTION FAILURE: incorrect record count' ,
                                'GuideAssert' );
    echo LSUnitTesting::assert( $iReccount === 6                                    ,
                                'ASSERTION SUCCESSFUL: Correct final record count'  ,
                                'ASSERTION FAILURE: incorrect final record count'   ,
                                'GuideAssert' );
    $oCursor->Close();
}

GuideAssert() ... ASSERTION SUCCESSFUL: Correct record count

GuideAssert() ... ASSERTION SUCCESSFUL: Correct final record count

Unit Testing

2 assertions: 2 successful; 0 failed

Average(): Calculates the average of a field

[ back to method list ]

Syntax

Average( $szField )

Parameters
NameTypeDescription
$szField string Field whose average must be calculated
Return

(float) The average

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/average.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
}

$oCursor->Save();

echo $oCursor->Average('@length');

echo LSUnitTesting::assert( $oCursor->Average('@length') === 10.0   ,
                            'ASSERTION SUCCESSFUL: average OK'      ,
                            'ASSERTION FAILURE: average NOT OK'     ,
                            'GuideAssert' );

10

GuideAssert() ... ASSERTION SUCCESSFUL: average OK

Unit Testing

1 assertions: 1 successful; 0 failed

BOF(): Determines if cursor is at beginning of file position

[ back to method list ]

Syntax

BOF()

Parameters

None

Return

(bool) true if cursor found at BOF; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

echo LSUnitTesting::assert( ! $oCursor->BOF()                                           ,
                            'ASSERTION SUCCESSFUL: Not BOF because file has no record'  ,
                            'ASSERTION FAILURE: Incorrect record pointer'               ,
                            'GuideAssert' );

$oCursor->Append( 'Event' );

echo LSUnitTesting::assert( $oCursor->BOF()                                     ,
                            'ASSERTION SUCCESSFUL: Beginning Of File detected'  ,
                            'ASSERTION FAILURE: Beginning of File NOT detected' ,
                            'GuideAssert' );

$oCursor->GoTop();

echo LSUnitTesting::assert( $oCursor->BOF()                                     ,
                            'ASSERTION SUCCESSFUL: Still BOF detected'          ,
                            'ASSERTION FAILURE: Beginning of File NOT detected' ,
                            'GuideAssert' );

$oCursor->GoBottom();
echo LSUnitTesting::assert( $oCursor->BOF()                                     ,
                            'ASSERTION SUCCESSFUL: BOF detected: 1 record only' ,
                            'ASSERTION FAILURE: End of File NOT detected'       ,
                            'GuideAssert' );
$oCursor->Skip();
echo LSUnitTesting::assert( ! $oCursor->BOF()                               ,
                            'ASSERTION SUCCESSFUL: passed EOF'              ,
                            'ASSERTION FAILURE: Incorrect record pointer'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: Not BOF because file has no record

GuideAssert() ... ASSERTION SUCCESSFUL: Beginning Of File detected

GuideAssert() ... ASSERTION SUCCESSFUL: Still BOF detected

GuideAssert() ... ASSERTION SUCCESSFUL: BOF detected: 1 record only

GuideAssert() ... ASSERTION SUCCESSFUL: passed EOF

Unit Testing

5 assertions: 5 successful; 0 failed

Change(): Switches the value of a logical field: 'true' becomes 'false' and vice versa

[ back to method list ]

Syntax

Change( $szValue )

Parameters
NameTypeDescription
$szValue string Value to be turned to its opposite. If 'false', becomes 'true'.
Return

(bool) false is returned if $szValue = 'true' || 'vrai' || 'yes' || 'oui' || 'waar' || 'ja' || 'on'; true otherwise.

Example(s)
echo $oCursor->Change( $oCursor->Field( 'WithData' ) );
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

echo LSUnitTesting::assert( ! $oCursor->Change('true')          ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('vrai')          ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('waar')          ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('yes')           ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('oui')           ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('ja')            ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( ! $oCursor->Change('on')            ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Change('any other value') ,
                            'ASSERTION SUCCESSFUL: good result' ,
                            'ASSERTION FAILURE: wrong result'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

GuideAssert() ... ASSERTION SUCCESSFUL: good result

Unit Testing

8 assertions: 8 successful; 0 failed

ClearMappings(): Clears all defined mappings

[ back to method list ]

Syntax

ClearMappings()

Parameters

None

Return

(void)

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Map( 'address','a' );

echo LSUnitTesting::assert( ! STR_Empty( $oCursor->IsMapped('address') )        ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );
$oCursor->ClearMappings();

echo LSUnitTesting::assert( STR_Empty( $oCursor->IsMapped('address') )          ,
                            'ASSERTION SUCCESSFUL: field unmapped successfully' ,
                            'ASSERTION FAILURE: clear mappings failure'         ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: field unmapped successfully

Unit Testing

2 assertions: 2 successful; 0 failed

Close(): Closes the cursor/table

[ back to method list ]

Syntax

Close()

Parameters

None

Return

(bool) true if table/db is successfully closed; false otherwise

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );
    $oCursor->Close();

    echo LSUnitTesting::assert( ! $oCursor->IsOpen()                                    ,
                                'ASSERTION SUCCESSFUL: cursor closed successfully'      ,
                                'ASSERTION FAILURE: cursor unexpectedly still opened'   ,
                                'GuideAssert' );
 }

GuideAssert() ... ASSERTION SUCCESSFUL: cursor closed successfully

Unit Testing

1 assertions: 1 successful; 0 failed

Connect(): Connects to the database/data file (if the underlying database format requires such connection).

[ back to method list ]

Syntax

Connect()

Parameters

None

Return

(bool) true if successfully connected; false otherwise and cursor pointer unchanged.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

echo LSUnitTesting::assert( $oCursor->Connect()                             ,
                            'ASSERTION SUCCESSFUL: successful connection'   ,
                            'ASSERTION FAILURE: cannot connect'             ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: successful connection

Unit Testing

1 assertions: 1 successful; 0 failed

Create(): Creates the physical cursor file

[ back to method list ]

Remark

It is not because the physical file has NOT been created that the cursor is invalid. If the physical filename the cursor must be saved to is not mentioned at the time this method is called, it can still be provided later (before a call to Save()).

Syntax

Create( $szDocumentElement,$szFile )

Parameters
NameTypeDescription
$szDocumentElement string Root Element
$szFile string Physical file name (bool) true if file created; false otherwise
Return

(bool) true if $szFile successfully created; false otherwise.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp' );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( null );

    echo '<p>Last error message after Create(): ',$szMsg = $oCursor->LastErrorMsg(),'</p>';

    echo LSUnitTesting::assert( STR_iPos( $szMsg,'Invalid document root' ) != -1,
                                'ASSERTION SUCCESSFUL: warning message received',
                                'ASSERTION FAILURE: no warning message: weird!' ,
                                'GuideAssert' );

    $oCursor->Create( 'whatever' );

    echo '<p>Last error message after Create(): ',$szMsg = $oCursor->LastErrorMsg(),'</p>';

    echo LSUnitTesting::assert( STR_iPos( $szMsg,'No physical filename' ) != -1 ,
                                'ASSERTION SUCCESSFUL: warning message received',
                                'ASSERTION FAILURE: no warning message: weird!' ,
                                'GuideAssert' );
}

Last error message after Create(): LSCursor::Create() at line 552: Invalid document root

GuideAssert() ... ASSERTION SUCCESSFUL: warning message received

Last error message after Create(): LSCursor::Create() at line 547: No physical filename mentioned

GuideAssert() ... ASSERTION SUCCESSFUL: warning message received

Unit Testing

2 assertions: 2 successful; 0 failed

DebugMsg(): Displays a debug message

[ back to method list ]

Syntax

DebugMsg( $szText,$szOrigin,$iLine )

Parameters
NameTypeDescription
$szText string Text to display
$szOrigin string Origin of the text (__FUNCTION__, __METHOD__, ...). Optional.
$iLine int Line of origin (__LINE__)
Return

(void)

Example Executed
$oCursor = new LSCursor( 'temp' );
echo '<p>',$oCursor->DebugMsg( 'Hello World','DEBUGMSG() ',361 ),'</p>';

DEBUGMSG() (361): Hello World

Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

Delete(): Soft deletes the current record (@active is set to 'no')

[ back to method list ]

Syntax

Delete()

Parameters

None

Return

(void)

Example(s)
$oCursor->Delete();
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );
    $oCursor->Append( 'item' );

    echo LSUnitTesting::assert( ! $oCursor->IsDeleted() && $oCursor->Reccount() === 1       ,
                                'ASSERTION SUCCESSFUL: item NOT deleted as expected'        ,
                                'ASSERTION FAILURE: item unexpectedly marked for deletion'  ,
                                'GuideAssert' );

    $oCursor->Delete();
    echo LSUnitTesting::assert( $oCursor->IsDeleted()                                       ,
                                'ASSERTION SUCCESSFUL: item marked for deletion as expected',
                                'ASSERTION FAILURE: item NOT marked for deletion'           ,
                                'GuideAssert' );
    $oCursor->Recall();
    echo LSUnitTesting::assert( ! $oCursor->IsDeleted()                             ,
                                'ASSERTION SUCCESSFUL: item recalled as expected'   ,
                                'ASSERTION FAILURE: item could ot be recalled'      ,
                                'GuideAssert' );
 }

GuideAssert() ... ASSERTION SUCCESSFUL: item NOT deleted as expected

GuideAssert() ... ASSERTION SUCCESSFUL: item marked for deletion as expected

GuideAssert() ... ASSERTION SUCCESSFUL: item recalled as expected

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

Remove(), Eliminate(), Recall()

DeleteMapping(): Deletes a mapping

[ back to method list ]

Syntax

DeleteMapping( $szLField )

Parameters
NameTypeDescription
$szLField string Logical field name
Return

(bool) true is $szLField mapping successfully deleted; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Map( 'firstname'  ,'f' );
$oCursor->Map( 'lastname'   ,'l' );
$oCursor->Map( 'address'    ,'a' );

echo LSUnitTesting::assert( count( $oCursor->GetMappings() ) === 3              ,
                            'ASSERTION SUCCESSFUL: correct number of mappings'  ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->DeleteMapping( 'address' )                ,
                            'ASSERTION SUCCESSFUL: field unmapped successfully' ,
                            'ASSERTION FAILURE: delete mapping failure'         ,
                            'GuideAssert' );

echo LSUnitTesting::assert( ! $oCursor->DeleteMapping( 'address' )                      ,
                            'ASSERTION SUCCESSFUL: cannot remove twice the same mapping',
                            'ASSERTION FAILURE: failure'                                ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of mappings

GuideAssert() ... ASSERTION SUCCESSFUL: field unmapped successfully

GuideAssert() ... ASSERTION SUCCESSFUL: cannot remove twice the same mapping

Unit Testing

3 assertions: 3 successful; 0 failed

DetailCount(): Returns the number of sub-records found in a record

[ back to method list ]

Syntax

DetailCount()

Parameters

None

Return

(int) Number of sub-records

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

$oCursor->Append( 'Events' );

for ( $i=0;$i<15;$i++ )
{
    $oCursor->Replace( "Entry/Event[new]/@time",date('H:i:s') . microtime(true) );
}

$oCursor->Field( "Entry/Event" );
$iCount = $oCursor->DetailCount();

$oCursor->Replace( "Entry/Event[{$iCount}]",'New event inserted at ' . time(),true );

echo LSUnitTesting::assert( $oCursor->DetailCount() === 15                      ,
                            'ASSERTION SUCCESSFUL: correct number of subrecords',
                            'ASSERTION FAILURE: incorrect number of subrecords' ,
                            'GuideAssert' );

$oCursor->Replace( "Entry/Event[new]/@time",date('H:i:s') . microtime(true) . 'LAST RECORD' );
$oCursor->Field( "Entry/Event" );

echo LSUnitTesting::assert( $oCursor->DetailCount() === 16                      ,
                            'ASSERTION SUCCESSFUL: correct number of subrecords',
                            'ASSERTION FAILURE: incorrect number of subrecords' ,
                            'GuideAssert' );

$oCursor->Save();

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of subrecords

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of subrecords

Unit Testing

2 assertions: 2 successful; 0 failed

Dirty(): Determines if the database/table contains uncommitted records

[ back to method list ]

Syntax

Dirty()

Parameters

None

Return

(bool) true if database/table contains uncommitted records; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';


if ( is_file( $szFile ) )
{
    FIL_Del( $szFile );
}

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Replace( '@id',SetID() );

    echo LSUnitTesting::assert( $oCursor->Dirty()                               ,
                                'ASSERTION SUCCESSFUL: Cursor dirty as expected',
                                'ASSERTION FAILURE: Cursor NOT dirty'           ,
                                'GuideAssert' );

    $oCursor->Save();

    echo LSUnitTesting::assert( ! $oCursor->Dirty()                                 ,
                                'ASSERTION SUCCESSFUL: Cursor NOT dirty as expected',
                                'ASSERTION FAILURE: Cursor dirty'                   ,
                                'GuideAssert' );

    $oCursor->Close();
}

GuideAssert() ... ASSERTION SUCCESSFUL: Cursor dirty as expected

GuideAssert() ... ASSERTION SUCCESSFUL: Cursor NOT dirty as expected

Unit Testing

2 assertions: 2 successful; 0 failed

dtos(): Turns a DD/MM/YYYY date into a YYYYMMDD date

[ back to method list ]

Syntax

dtos( $szDate )

Parameters
NameTypeDescription
$szDate string A DD/MM/YYYY date
Return

(string) a YYYYMMDD date or null

Example Executed
$oCursor = new LSCursor( 'Events' );

echo "<p>",$szDate1 = $oCursor->dtos( '12/31/2013' ),"</p>";

echo LSUnitTesting::assert( $szDate1 === '20131231'                     ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo "<p>",$szDate1 = $oCursor->dtos( '31/12/2013' ),"</p>";

echo LSUnitTesting::assert( $szDate1 === '20131231'                     ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

20131231

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

20131231

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

Unit Testing

2 assertions: 2 successful; 0 failed

Eliminate(): Eliminates/Deletes a field of the current record. The field is removed physically = removed from the record.

[ back to method list ]

Warning

This method is supported for XML databases only

Syntax

Eliminate( $szField )

Parameters
NameTypeDescription
$szField string the field that must be deleted
Return

(bool) true if Eliminate() is successful; false otherwise

Example(s)
if ( STR_Empty( $szAttachment ) )
{
    $oCursor->Eliminate( 'Attachment' );
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

$oCursor->Append( 'Events' );

for ( $i=0;$i<15;$i++ )
{
    $oCursor->Replace( "Entry/Event[new]/@time",date('H:i:s') . microtime(true) );
}

$oCursor->Replace( "Entry/Event[10]/Hello",'I am saying hello' );

$oCursor->Eliminate( 'Entry/Event[10]/Hello' );

echo LSUnitTesting::assert( is_null( $oCursor->Field( 'Entry/Event[10]/Hello' ) )   ,
                            'ASSERTION SUCCESSFUL: Hello field removed'             ,
                            'ASSERTION FAILURE: Hello field NOT removed'            ,
                            'GuideAssert' );
$oCursor->Save();

GuideAssert() ... ASSERTION SUCCESSFUL: Hello field removed

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

Remove(), Delete(), Recall()

EOF(): Determines if cursor is at end of file position

[ back to method list ]

Syntax

EOF()

Parameters

None

Return

(bool) true if cursor found at EOF; false otherwise

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );
$oCursor->GoBottom();
$oCursor->Skip();

echo LSUnitTesting::assert( $oCursor->EOF()                                 ,
                            'ASSERTION SUCCESSFUL: End Of File detected'    ,
                            'ASSERTION FAILURE: End of File NOT detected'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: End Of File detected

Unit Testing

1 assertions: 1 successful; 0 failed

Field(): Returns the value of a field

[ back to method list ]

Syntax

Field( $xField,$szFnc,$iSkip )

Parameters
NameTypeDescription
$xField string Field to look for (can also be an array)
$szFnc string Callback function
$iSkip integer Skip X records
Return

(mixed) Value of the field or null if not found. If callback function provided then, it is the return value of the callback.

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Name = 'John Doe';

    $oCursor->Save();

    echo LSUnitTesting::assert( $oCursor->Field( 'Name' ) === 'John Doe'                ,
                                'ASSERTION SUCCESSFUL: property successfully retrieved' ,
                                'ASSERTION FAILURE: incorrect property value'           ,
                                'GuideAssert' );
    $oCursor->Close();
}

GuideAssert() ... ASSERTION SUCCESSFUL: property successfully retrieved

Unit Testing

1 assertions: 1 successful; 0 failed

FileExists(): Determines if a file exists

[ back to method list ]

Syntax

FileExists( $szFile )

Parameters
NameTypeDescription
$szFile string Optional file to check existance of. Equal to the internal datasource by default.
Return

(bool) true if $szFile exists; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

$oCursor = new LSCursor( 'temp',$szFile );

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

echo LSUnitTesting::assert( ! $oCursor->FileExists( $szFile )                                    ,
                            'ASSERTION SUCCESSFUL: ' . basename( $szFile ) .
                                                   ' does NOT exist (which is what we expected)' ,
                            'ASSERTION FAILURE: '    . basename( $szFile ) . ' exists!'          ,
                            'GuideAssert' );

$oCursor->Create( 'whatever',$szFile );

echo LSUnitTesting::assert( $oCursor->FileExists( $szFile )                                     ,
                            'ASSERTION SUCCESSFUL: after cursor creation the file should exist!',
                            'ASSERTION FAILURE: '    . basename( $szFile ) . ' does not exists' ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->FileExists()                                      ,
                            'ASSERTION SUCCESSFUL: '                                    .
                                basename( $oCursor->szDataSource ) . ' exists'          ,
                            'ASSERTION FAILURE: '                                       .
                                basename( $oCursor->szDataSource ) . ' does NOT exists' ,
                            'GuideAssert' );

$oCursor->Close();
echo LSUnitTesting::assert( $oCursor->FileExists( $szFile )                                 ,
                            'ASSERTION SUCCESSFUL: the file still exists even after close'  ,
                            'ASSERTION FAILURE: ' . basename( $szFile ) . ' does not exist' ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: temp.xml does NOT exist (which is what we expected)

GuideAssert() ... ASSERTION SUCCESSFUL: after cursor creation the file should exist!

GuideAssert() ... ASSERTION SUCCESSFUL: temp.xml exists

GuideAssert() ... ASSERTION SUCCESSFUL: the file still exists even after close

Unit Testing

4 assertions: 4 successful; 0 failed

GetMappings(): Get all defined mappings

[ back to method list ]

Syntax

GetMappings()

Parameters

None

Return

(array) An array of mappings. Logical field names are keys of the returned array whereas values are physical field names.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$aMappings = $oCursor->GetMappings();

echo LSUnitTesting::assert( count( $aMappings ) === 0               ,
                            'ASSERTION SUCCESSFUL: empty array'     ,
                            'ASSERTION FAILURE: not an empty array' ,
                            'GuideAssert' );

$oCursor->Map( 'firstname'  ,'f' );
$oCursor->Map( 'lastname'   ,'l' );
$oCursor->Map( 'address'    ,'a' );

$aMappings = $oCursor->GetMappings();

echo LSUnitTesting::assert( is_array( $aMappings )                          ,
                            'ASSERTION SUCCESSFUL: mappings are an array'   ,
                            'ASSERTION FAILURE: not an array'               ,
                            'GuideAssert' );

echo LSUnitTesting::assert( count( $aMappings ) === 3 ,
                            'ASSERTION SUCCESSFUL: correct number of mappings'      ,
                            'ASSERTION FAILURE: field mapping failure'              ,
                            'GuideAssert' );

$szPHPCode0 = var_export( $oCursor->GetMappings(),true );
$szPHPCode1 = var_export( $aMappings,true );
$aMappings['firstname'] = 'target field changed';
$szPHPCode2 = var_export( $aMappings,true );

echo LSUnitTesting::assert( $szPHPCode0 === $szPHPCode1                     ,
                            'ASSERTION SUCCESSFUL: identical array copies'  ,
                            'ASSERTION FAILURE: copies NOT identical'       ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $szPHPCode0 != $szPHPCode2                          ,
                            'ASSERTION SUCCESSFUL: changing the value of a '  .
                            'mapping in the returned array<br />does not '    .
                            'affect the mappings in the cursor'                 ,
                            'ASSERTION FAILURE: internal mappings affected'     ,
                            'GuideAssert' );

$oCursor->ClearMappings();

echo LSUnitTesting::assert( STR_Empty( $oCursor->IsMapped('address') )          ,
                            'ASSERTION SUCCESSFUL: field unmapped successfully' ,
                            'ASSERTION FAILURE: clear mappings failure'         ,
                            'GuideAssert' );

echo LSUnitTesting::assert( count( $oCursor->GetMappings() ) === 0              ,
                            'ASSERTION SUCCESSFUL: correct number of mappings'  ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: empty array

GuideAssert() ... ASSERTION SUCCESSFUL: mappings are an array

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of mappings

GuideAssert() ... ASSERTION SUCCESSFUL: identical array copies

GuideAssert() ... ASSERTION SUCCESSFUL: changing the value of a mapping in the returned array
does not affect the mappings in the cursor

GuideAssert() ... ASSERTION SUCCESSFUL: field unmapped successfully

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of mappings

Unit Testing

7 assertions: 7 successful; 0 failed

GetReccount(): Calculates the number of records in the current table

[ back to method list ]

Caution

This method is only supported for SQL databases such as SQLite3

Syntax

GetReccount()

Parameters

None

Return

(int) Record count or -1 if failure

Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

GetXML(): Gets the whole XML of the DB (corresponding to all the records)

[ back to method list ]

Remark

The whole XML is returned, no matter what type of filter is actually set

Syntax

GetXML()

Alias

__toString()

TODO

Il faut constituer le XML correspondant à un curseur de type SQLITE3

Parameters

None

Return

(string) XML string of the whole DB (can be extremely large).

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Create( 'Records',$szFile );
$oCursor->Append( 'Item' );
$oCursor->Replace( 'Event','A new event will start on 20141231' );

echo "<pre>",wordwrap( htmlentities( $szXML = $oCursor->GetXML() ) ),"</pre>";

echo LSUnitTesting::assert( ! STR_Empty( $szXML )                               ,
                            'ASSERTION SUCCESSFUL: XML returned as expected'    ,
                            'ASSERTION FAILURE: no XML returned'                ,
                            'GuideAssert' );

echo LSUnitTesting::assert( STR_Pos( $szXML,'<Event>A new event will' ) !== -1  ,
                            'ASSERTION SUCCESSFUL: found my event back!'        ,
                            'ASSERTION FAILURE: where is my event?'             ,
                            'GuideAssert' );

<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<Records xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vae="urn:lato-sensu-management/Vaesoli"
xmlns:quitus="urn:lato-sensu-management/Quitus">
<Item><Event>A new event will start on
20141231</Event></Item></Records>

GuideAssert() ... ASSERTION SUCCESSFUL: XML returned as expected

GuideAssert() ... ASSERTION SUCCESSFUL: found my event back!

Unit Testing

2 assertions: 2 successful; 0 failed

Go(): Go to a specific record number

[ back to method list ]

Syntax

Go( $n )

Parameters
NameTypeDescription
$n int Record number we need to jump to
Return

(int) old record position or -1 if problem

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

for ( $i = 0; $i < 100;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@number',$i );
}

$oCursor->Go( 17 );
echo LSUnitTesting::assert( $oCursor->Recno() === 17                        ,
                            'ASSERTION SUCCESSFUL: record pointer OK'       ,
                            'ASSERTION FAILURE: Incorrect record pointer'   ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Go( 3000 ) === -1                     ,
                            'ASSERTION SUCCESSFUL: record pointer OK'       ,
                            'ASSERTION FAILURE: Incorrect record pointer'   ,
                            'GuideAssert' );

$oCursor->Go( $oCursor->Recno() );
echo LSUnitTesting::assert( $oCursor->Recno() !== -1                        ,
                            'ASSERTION SUCCESSFUL: record pointer OK'       ,
                            'ASSERTION FAILURE: Incorrect record pointer'   ,
                            'GuideAssert' );

$oCursor->Go( $x = rand( 1,$oCursor->Reccount() ) );
echo LSUnitTesting::assert( $oCursor->Recno() === $x                        ,
                            'ASSERTION SUCCESSFUL: record pointer OK'       ,
                            'ASSERTION FAILURE: Incorrect record pointer'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer OK

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer OK

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer OK

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer OK

Unit Testing

4 assertions: 4 successful; 0 failed

GoBottom(): Go to the last record

[ back to method list ]

Syntax

GoBottom()

Parameters

None

Return

(int) Previous record pointer position before jumping to the last record or -1 in case of problem

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

for ( $i = 0; $i < 100;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@number',$i );
}

$oCursor->GoTop();
$iFirst = $oCursor->Recno();
$oCursor->GoBottom();
$iLast  = $oCursor->Recno();

echo LSUnitTesting::assert( $iLast === $oCursor->Reccount()                         ,
                            'ASSERTION SUCCESSFUL: last record correctly detected'  ,
                            'ASSERTION FAILURE: last record not detected'           ,
                            'GuideAssert' );

$oCursor->Skip();

echo LSUnitTesting::assert( $oCursor->EOF()                                     ,
                            'ASSERTION SUCCESSFUL: EOF expected'                ,
                            'ASSERTION FAILURE: EOF not detected as expected'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: last record correctly detected

GuideAssert() ... ASSERTION SUCCESSFUL: EOF expected

Unit Testing

2 assertions: 2 successful; 0 failed

GoTop(): Go to the first record

[ back to method list ]

Syntax

GoTop()

Parameters

None

Return

(int) Previous record pointer position before jumping to the first record or -1 in case of problem

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Calendar',$szFile );

$oCursor->Create( 'Calendar',$szFile );

for ( $i = 0; $i < 100;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@number',$i );
}

$iRecno = $oCursor->GoTop();

echo LSUnitTesting::assert( $iRecno === 100                                 ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: record pointer correct'     ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Recno() === 1                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: record pointer correct'     ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

Unit Testing

2 assertions: 2 successful; 0 failed

Guid(): Returns a GUID (unique in time, unique in space)

[ back to method list ]

Syntax

Guid( $WithCurlies )

Parameters
NameTypeDescription
$WithCurlies bool Optional parameter that indicates whether curly braces should be added to the return value. false by default
Return

(string) GUID

Example Executed
$oCursor = new LSCursor( 'Events' );

echo LSUnitTesting::assert( ! STR_Empty( $szGUID = $oCursor->Guid() )   ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo "<p>GUID: ",$szGUID,"</p>";

echo LSUnitTesting::assert( preg_match( '/\{.{5,}\}/si',$oCursor->Guid( true ) ),
                            'ASSERTION SUCCESSFUL: result OK with curly braces' ,
                            'ASSERTION FAILURE: no curly braces detected'       ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

GUID: DB243961-C5FF-4C3F-BC7C-4428CBF81A6A

GuideAssert() ... ASSERTION SUCCESSFUL: result OK with curly braces

Unit Testing

2 assertions: 2 successful; 0 failed

Hours(): Keeps the 'HH' part of a 'HH:MM[:SS]' string

[ back to method list ]

Syntax

Hours( $szTime )

Parameters
NameTypeDescription
$szTime string "HH:MM[:SS]" string
Return

(string) 'HH' of $szTime

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );

echo LSUnitTesting::assert( $oCursor->Hours( '12:35:42' ) === '12'  ,
                            'ASSERTION SUCCESSFUL: hours correct'   ,
                            'ASSERTION FAILURE: hours incorrect'    ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: hours correct

Unit Testing

1 assertions: 1 successful; 0 failed

Index(): Index the cursor/table on a specific field (values MUST be unique)

[ back to method list ]

Caution

The Index() method must be used with caution. The key on which the index is to be created SHOULD be unique as the SeekIndex() method will always retrieve the first match. Therefore, having two keys with exactly the same value, may cause some trouble when trying to resolve duplicates.

Similarly setting a filter on the database/table influences the outcome of the Index() method as only the records matching the filter will be indexed.

Last but not least, ordering the table and then indexing may influence the result of the SeekIndex() method.

Our recommendation is to index unordered and unfiltered databases/tables unless you know exactly what you do.

Syntax

Index( $szField,$szIDXFile )

Parameters
NameTypeDescription
$szField string Field on which the index is produced
$szIDXFile string Name of the output index file. Optional. if $szIDXFile is not mentioned, the index is called exactly the same way as the original cursor with an .idx extension instead.
Return

(bool) true if table/db successfully indexed; false otherwise

Example Executed
$szFile = 'c:\\WebSites\\ui.tl\\www\\databases\\uikey.xml';

$oCursor = new LSCursor( 'temp',$szFile );

if ( $oCursor->Open() )
{
    echo LSUnitTesting::assert( $oCursor->Index( 'K' )                              ,
                                'ASSERTION SUCCESSFUL: cursor indexed successfully' ,
                                'ASSERTION FAILURE: cursor could not be indexed'    ,
                                'GuideAssert' );

    $time1 = microtime(true);
    $iRecord = $oCursor->SeekIndex( 'KM-SMALL' );
    $time2 = microtime(true);

    echo LSUnitTesting::assert( ( $iRecord != -1 )                                  ,
                                'ASSERTION SUCCESSFUL: KM-SMALL found as expected'  ,
                                'ASSERTION FAILURE: KM-SMALL NOT found!'            ,
                                'GuideAssert' );
    echo "<p>KM-SMALL found in ",( $fTimeIdx = ( ( $time2 - $time1 ) * 1000 ) ),"ms at record #{$iRecord}</p>\n";
}

GuideAssert() ... ASSERTION SUCCESSFUL: cursor indexed successfully

GuideAssert() ... ASSERTION SUCCESSFUL: KM-SMALL found as expected

KM-SMALL found in 0.65302848815918ms at record #6951

Unit Testing

2 assertions: 2 successful; 0 failed

IsDeleted(): Determines if a record is soft deleted or not

[ back to method list ]

Syntax

IsDeleted()

Parameters

None

Return

(bool) true if current record soft deleted; false otherwise

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    // Remove all soft deleted records
    while( ! $oCursor->EOF() )
    {
        if ( $oCursor->IsDeleted() )
        {
            $oCursor->Remove();
        }
        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );
    $oCursor->Append( 'item' );

    echo LSUnitTesting::assert( ! $oCursor->IsDeleted() && $oCursor->Reccount() === 1       ,
                                'ASSERTION SUCCESSFUL: item NOT deleted as expected'        ,
                                'ASSERTION FAILURE: item unexpectedly marked for deletion'  ,
                                'GuideAssert' );

    $oCursor->Delete();
    echo LSUnitTesting::assert( $oCursor->IsDeleted()                                       ,
                                'ASSERTION SUCCESSFUL: item marked for deletion as expected',
                                'ASSERTION FAILURE: item NOT marked for deletion'           ,
                                'GuideAssert' );
    $oCursor->Recall();
    echo LSUnitTesting::assert( ! $oCursor->IsDeleted()                             ,
                                'ASSERTION SUCCESSFUL: item recalled as expected'   ,
                                'ASSERTION FAILURE: item could ot be recalled'      ,
                                'GuideAssert' );
 }

GuideAssert() ... ASSERTION SUCCESSFUL: item NOT deleted as expected

GuideAssert() ... ASSERTION SUCCESSFUL: item marked for deletion as expected

GuideAssert() ... ASSERTION SUCCESSFUL: item recalled as expected

Unit Testing

3 assertions: 3 successful; 0 failed

IsMapped(): Determines if a field has been mapped

[ back to method list ]

Syntax

IsMapped( $szLField )

Parameters
NameTypeDescription
$szLField string Logical field name
Return

(string) Physical field name is $szLField is mapped, or null if not.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Map( 'address','a' );
$oCursor->Map( 'First Name' ,'f' );
$oCursor->Map( 'Last Name'  ,'l' );

echo LSUnitTesting::assert( ! STR_Empty( $oCursor->IsMapped('address') )        ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->IsMapped('address') === 'a'                   ,
                            'ASSERTION SUCCESSFUL: "address" successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'              ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->IsMapped('First Name') === 'f'                ,
                            'ASSERTION SUCCESSFUL: "First Name" successfully mapped',
                            'ASSERTION FAILURE: field mapping failure'              ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->IsMapped('Last Name') === 'l'                 ,
                            'ASSERTION SUCCESSFUL: "Last Name" successfully mapped',
                            'ASSERTION FAILURE: field mapping failure'              ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Field('Last Name') === $oCursor->Field('l')   ,
                            'ASSERTION SUCCESSFUL: "First Name" successfully mapped',
                            'ASSERTION FAILURE: field mapping failure'              ,
                            'GuideAssert' );
echo LSUnitTesting::assert( STR_Empty( $oCursor->IsMapped('last name')  )           ,
                            'ASSERTION SUCCESSFUL: mapping is case sensitive'       ,
                            'ASSERTION FAILURE: mapping is case sensitive'          ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: "address" successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: "First Name" successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: "Last Name" successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: "First Name" successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: mapping is case sensitive

Unit Testing

6 assertions: 6 successful; 0 failed

IsOpen(): Determines if the cursor/table is open

[ back to method list ]

Syntax

IsOpen()

Parameters

None

Return

(bool) true if table is open; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/events.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
}

$oCursor->Save();
$oCursor->Close();
$oCursor->Open();

echo LSUnitTesting::assert( $oCursor->FileExists()  &&
                            $oCursor->IsOpen()      &&
                            $oCursor->Reccount() === 5                                      ,
                            'ASSERTION SUCCESSFUL: cursor saved and reopened successfully'  ,
                            'ASSERTION FAILURE: not the result we expected'                 ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: cursor saved and reopened successfully

Unit Testing

1 assertions: 1 successful; 0 failed

IsTargetField(): Determines if a field is a target of a mapping

[ back to method list ]

Syntax

IsTargetField( $szPField )

Parameters
NameTypeDescription
$szPField string Physical field name to check
Return

(bool) true is $szPField is the target field of a mapping; false if not.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Map( 'address','a' );
$oCursor->Map( 'First Name' ,'f' );
$oCursor->Map( 'Last Name'  ,'l' );

echo LSUnitTesting::assert( $oCursor->IsTargetField('a')                    ,
                            'ASSERTION SUCCESSFUL: "a" is a target field'   ,
                            'ASSERTION FAILURE: "a" is NOT a target field'  ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->IsTargetField('f')                    ,
                            'ASSERTION SUCCESSFUL: "f" is a target field'   ,
                            'ASSERTION FAILURE: "f" is NOT a target field'  ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->IsTargetField('l')                    ,
                            'ASSERTION SUCCESSFUL: "l" is a target field'   ,
                            'ASSERTION FAILURE: "l" is NOT a target field'  ,
                            'GuideAssert' );

echo LSUnitTesting::assert( ! $oCursor->IsTargetField('x')                      ,
                            'ASSERTION SUCCESSFUL: "x" is NOT a target field'   ,
                            'ASSERTION FAILURE: "x" is a target field'          ,
                            'GuideAssert' );

echo LSUnitTesting::assert( ! $oCursor->IsTargetField('First Name')                     ,
                            'ASSERTION SUCCESSFUL: "First Name" is NOT a target field'  ,
                            'ASSERTION FAILURE: "First Name" is a target field'         ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: "a" is a target field

GuideAssert() ... ASSERTION SUCCESSFUL: "f" is a target field

GuideAssert() ... ASSERTION SUCCESSFUL: "l" is a target field

GuideAssert() ... ASSERTION SUCCESSFUL: "x" is NOT a target field

GuideAssert() ... ASSERTION SUCCESSFUL: "First Name" is NOT a target field

Unit Testing

5 assertions: 5 successful; 0 failed

LastErrorMsg(): Returns the last error message

[ back to method list ]

Syntax

LastErrorMsg()

Parameters

None

Return

(string) The last error message or null if NO error message registered

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    echo '<p>Last error message after Create(): ',$szMsg = $oCursor->LastErrorMsg(),'</p>';

    echo LSUnitTesting::assert( STR_Empty( $szMsg )                     ,
                                'ASSERTION SUCCESSFUL: no error message',
                                'ASSERTION FAILURE: empty error message',
                                'GuideAssert' );


    $oCursor->Replace( 'Name','John Doe' );
    echo '<p>Last error message after Replace(): ',$szMsg = $oCursor->LastErrorMsg(),'</p>';

    if ( preg_match( '/LSCursor::Replace\(\) +at +line +(?P<line>\d{1,5}):' .
                     ' +invalid +record/si',$szMsg,$aError ) )
    {
    	$iLine = (int) $aError['line'];
    }
    else
    {
    	$iLine = -1;
    }

    echo LSUnitTesting::assert( ( ! STR_Empty( $szMsg ) ) && ( $iLine > 0 )             ,
                                "ASSERTION SUCCESSFUL: error message at line {$iLine}"  ,
                                'ASSERTION FAILURE: empty error message'                ,
                                'GuideAssert' );
}

Last error message after Create():

GuideAssert() ... ASSERTION SUCCESSFUL: no error message

Last error message after Replace(): LSCursor::Replace() at line 4030: invalid record (node null)

GuideAssert() ... ASSERTION SUCCESSFUL: error message at line 4030

Unit Testing

2 assertions: 2 successful; 0 failed

Map(): Maps a logical field to a physical field

[ back to method list ]

Caution

No check of any sort is performed on mappings. Make sure you do not define circular mappings because it can generate unpredictable results. Mapping a target field (a field that is the physical field name corresponding to a logical field name) can also generate such unpredictable results.

Syntax

Map( $szLField,$szPField )

Parameters
NameTypeDescription
$szLField string Logical field name
$szPField string Physical field name
Return

(void)

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );
$oCursor->Create( 'Records' );
$oCursor->Append( 'Item' );

$oCursor->Map( 'address','a' );
$oCursor->Replace( 'address','Hello, This is my address' );

echo LSUnitTesting::assert( $oCursor->Field('a') === 'Hello, This is my address' ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Field('address') === 'Hello, This is my address' ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Field('address') === $oCursor->Field('a') ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->IsMapped('address')                       ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->IsTargetField('a')                        ,
                            'ASSERTION SUCCESSFUL: field successfully mapped'   ,
                            'ASSERTION FAILURE: field mapping failure'          ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

GuideAssert() ... ASSERTION SUCCESSFUL: field successfully mapped

Unit Testing

5 assertions: 5 successful; 0 failed

Max(): Determines the maximum value of a field

[ back to method list ]

Syntax

Max( $szField )

Parameters
NameTypeDescription
$szField string Field whose maximum value must be determined
Return

(mixed) The maximum

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/maximum.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
    $oCursor->Replace( '@value',str_repeat( 'a',$i+1 ) );
}

$oCursor->Save();

echo '<p>@LENGTH: ',$oCursor->Max('@length'),'</p>';
echo '<p>@VALUE: ' ,$oCursor->Max('@value'),'</p>';

echo LSUnitTesting::assert( (float) $oCursor->Max('@length') === 20.0   ,
                            'ASSERTION SUCCESSFUL: maximum OK'          ,
                            'ASSERTION FAILURE: maximum NOT OK'         ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Max('@value') === 'aaaaa'     ,
                            'ASSERTION SUCCESSFUL: maximum OK'      ,
                            'ASSERTION FAILURE: maximum NOT OK'     ,
                            'GuideAssert' );

@LENGTH: 20

@VALUE: aaaaa

GuideAssert() ... ASSERTION SUCCESSFUL: maximum OK

GuideAssert() ... ASSERTION SUCCESSFUL: maximum OK

Unit Testing

2 assertions: 2 successful; 0 failed

Min(): Determines the minimum value of a field

[ back to method list ]

Syntax

Min( $szField )

Parameters
NameTypeDescription
$szField string Field whose minimum value must be determined
Return

(mixed) The minimum

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/minimum.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
    $oCursor->Replace( '@value',str_repeat( 'a',$i+1 ) );
}

$oCursor->Save();

echo '<p>@LENGTH: ',$oCursor->Min('@length'),'</p>';
echo '<p>@VALUE: ' ,$oCursor->Min('@value'),'</p>';

echo LSUnitTesting::assert( (float) $oCursor->Min('@length') === 0.0,
                            'ASSERTION SUCCESSFUL: minimum OK'      ,
                            'ASSERTION FAILURE: minimum NOT OK'     ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Min('@value') === 'a'         ,
                            'ASSERTION SUCCESSFUL: minimum OK'      ,
                            'ASSERTION FAILURE: minimum NOT OK'     ,
                            'GuideAssert' );

@LENGTH: 0

@VALUE: a

GuideAssert() ... ASSERTION SUCCESSFUL: minimum OK

GuideAssert() ... ASSERTION SUCCESSFUL: minimum OK

Unit Testing

2 assertions: 2 successful; 0 failed

Minutes(): Keeps the 'MM' part of a 'HH:MM' string

[ back to method list ]

Syntax

Minutes( $szHourMin )

Parameters
NameTypeDescription
$szHourMin string "HH:MM" string
Return

(string) 'MM' of $szHourMin

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );

echo LSUnitTesting::assert( $oCursor->Minutes( '12:35:42' ) === '35',
                            'ASSERTION SUCCESSFUL: minutes correct' ,
                            'ASSERTION FAILURE: minutes incorrect'  ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: minutes correct

Unit Testing

1 assertions: 1 successful; 0 failed

Now(): Formats the current time in YYYYMMDDHHmmSS

[ back to method list ]

Syntax

Now()

Parameters

None

Return

(string) Current time in YYYYMMDDHHmmSS format

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );

echo LSUnitTesting::assert( $oCursor->Now() === date( 'YmdHis' ),
                            'ASSERTION SUCCESSFUL: this is now' ,
                            'ASSERTION FAILURE: time problem'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: this is now

Unit Testing

1 assertions: 1 successful; 0 failed

Open(): Opens the cursor/table

[ back to method list ]

Syntax

Open()

Parameters

None

Return

(bool) true if table/db is successfully open; false otherwise

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );
    $oCursor->Close();
    $oCursor->Open();

    echo LSUnitTesting::assert( $oCursor->IsOpen()                                  ,
                                'ASSERTION SUCCESSFUL: cursor successfully open'    ,
                                'ASSERTION FAILURE: cursor unexpectedly still closed',
                                'GuideAssert' );
 }

GuideAssert() ... ASSERTION SUCCESSFUL: cursor successfully open

Unit Testing

1 assertions: 1 successful; 0 failed

Recall(): Soft recalls the current record (@active is set to 'yes')

[ back to method list ]

Syntax

Recall()

Parameters

None

Return

(void)

Example(s)
$oCursor->Recall();
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );
    $oCursor->Append( 'item' );
    $oCursor->Delete();
    echo LSUnitTesting::assert( $oCursor->IsDeleted()                                       ,
                                'ASSERTION SUCCESSFUL: item marked for deletion as expected',
                                'ASSERTION FAILURE: item NOT marked for deletion'           ,
                                'GuideAssert' );
    $oCursor->Recall();
    echo LSUnitTesting::assert( ! $oCursor->IsDeleted()                             ,
                                'ASSERTION SUCCESSFUL: item recalled as expected'   ,
                                'ASSERTION FAILURE: item could ot be recalled'      ,
                                'GuideAssert' );
 }

GuideAssert() ... ASSERTION SUCCESSFUL: item marked for deletion as expected

GuideAssert() ... ASSERTION SUCCESSFUL: item recalled as expected

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

Remove(), Eliminate(), Delete()

Reccount(): Returns the number of records found in the cursor (or table)

[ back to method list ]

Syntax

Reccount()

Parameters

None

Return

(int) Number of records or -1 if failure

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';


if ( is_file( $szFile ) )
{
    FIL_Del( $szFile );
}

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Replace( '@id',SetID() );

    $iReccount1 = $oCursor->Reccount();

    for ( $i = 1; $i <=5; $i++ )
    {
        $oCursor->Append( 'Item' );
        $oCursor->Replace( '@id',SetID() );
    }

    $iReccount = $oCursor->Reccount();

    $oCursor->Save();

    echo LSUnitTesting::assert( $iReccount1 === 1                           ,
                                'ASSERTION SUCCESSFUL: Correct record count',
                                'ASSERTION FAILURE: incorrect record count' ,
                                'GuideAssert' );
    echo LSUnitTesting::assert( $iReccount === 6                                    ,
                                'ASSERTION SUCCESSFUL: Correct final record count'  ,
                                'ASSERTION FAILURE: incorrect final record count'   ,
                                'GuideAssert' );
    $oCursor->Close();

}

GuideAssert() ... ASSERTION SUCCESSFUL: Correct record count

GuideAssert() ... ASSERTION SUCCESSFUL: Correct final record count

Unit Testing

2 assertions: 2 successful; 0 failed

Recno(): Returns the current record position

[ back to method list ]

Syntax

Recno()

Parameters

None

Return

(int) Current record position or -1 if the record position cannot be determined

Example Executed
$szFile  = FIL_Normalize( FIL_ResolveRoot( "/vaesoli/include/ut/uad.xml" ) );
$oCursor = new LSCursor( 'User Account Database',$szFile );

$oCursor->Open();

echo LSUnitTesting::assert( $oCursor->Recno() === 1                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );
$oCursor->Skip();
echo LSUnitTesting::assert( $oCursor->Recno() === 2                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );
$oCursor->Skip();
echo LSUnitTesting::assert( $oCursor->Recno() === 3                         ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->EOF()                                 ,
                            'ASSERTION SUCCESSFUL: end of file detected'    ,
                            'ASSERTION FAILURE: end of file NOT detected'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Close()                                   ,
                            'ASSERTION SUCCESSFUL: cursor closed successfully'  ,
                            'ASSERTION FAILURE: cannot close cursor'            ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Recno() === -1                        ,
                            'ASSERTION SUCCESSFUL: record pointer correct'  ,
                            'ASSERTION FAILURE: incorrect record pointer'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

GuideAssert() ... ASSERTION SUCCESSFUL: end of file detected

GuideAssert() ... ASSERTION SUCCESSFUL: cursor closed successfully

GuideAssert() ... ASSERTION SUCCESSFUL: record pointer correct

Unit Testing

6 assertions: 6 successful; 0 failed

Record(): Returns the current record as XML

[ back to method list ]

Syntax

Record()

Parameters

None

Return

(string) XML string corresponding to the record or null if problem

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/tmp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
    $oCursor->Replace( 'Amount', rand(4,7) * 8 );
    $oCursor->Replace( 'Amount/@unit','EUR' );
}

$oCursor->Go( 3 );
echo "<pre>",htmlentities( $szXML = $oCursor->Record() ),"</pre>";

echo LSUnitTesting::assert( preg_match( '/<Event +length="10"/si',$szXML )  ,
                            'ASSERTION SUCCESSFUL: looks OK'                ,
                            'ASSERTION FAILURE: does not look OK'           ,
                            'GuideAssert' );

<Event length="10">
  <Amount unit="EUR">32</Amount>
</Event>

GuideAssert() ... ASSERTION SUCCESSFUL: looks OK

Unit Testing

1 assertions: 1 successful; 0 failed

RegisterEvent(): Register event

[ back to method list ]

Syntax

RegisterEvent( $szEventName,$szFnc )

Parameters
NameTypeDescription
$szEventName string The name of the event to which a function should be attached.
append event triggered when a new record is added
save event triggered when the database/table is saved
create event triggered when a new record is created
sort event triggered when sorting the database/table
open event triggered when opening a database/table
replace event triggered when replacing the value of a field
requery event triggered when requerying the data
flush event triggered when flushing the database/table
close event triggered when closing a database/table
$szFnc string The name of a function to execute
Return

(bool) true if even successfully registered; false otherwise.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    global $xDestructVar;
    $xDestructVar = 'Any Value';

    $oCursor->RegisterEvent( 'open'     ,'UTEvent' );
    $oCursor->RegisterEvent( 'close'    ,'UTEvent' );
    $oCursor->RegisterEvent( 'append'   ,'UTEvent' );
    $oCursor->RegisterEvent( 'replace'  ,'UTEvent' );
    $oCursor->RegisterEvent( 'save'     ,'UTEvent' );

    $oCursor->Create( 'whatever',$szFile );

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'OPEN'               ,
                                'ASSERTION SUCCESSFUL: cursor successfully opened'  ,
                                'ASSERTION FAILURE: event playback failed'          ,
                                'GuideAssert' );

    $oCursor->Append( 'Item' );

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'APPEND'             ,
                                'ASSERTION SUCCESSFUL: append playback successful'  ,
                                'ASSERTION FAILURE: append playback failure'        ,
                                'GuideAssert' );

    $oCursor->Replace( '@id',SetID() );
    $oCursor->Replace( 'Name','John Doe' );

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'REPLACE'                        ,
                                'ASSERTION SUCCESSFUL: field replacement playback successful'   ,
                                'ASSERTION FAILURE: field replacement playback failure'         ,
                                'GuideAssert' );

    $oCursor->Close();

    echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'CLOSE'                          ,
                                'ASSERTION SUCCESSFUL: close event successfully played back'    ,
                                'ASSERTION FAILURE: incorrect close event'                      ,
                                'GuideAssert' );
}

function UTEvent( $oCursor,$szEvent )
{
    switch ( strtolower( $szEvent ) )
    {
        case 'save'     :   die("SAVE");
                            break;
        case 'open'     :
        case 'close'    :
        case 'append'   :
        case 'replace'  :   $GLOBALS[ 'xDestructVar' ] = strtoupper( $szEvent );
                            break;
    }
}

GuideAssert() ... ASSERTION SUCCESSFUL: cursor successfully opened

GuideAssert() ... ASSERTION SUCCESSFUL: append playback successful

GuideAssert() ... ASSERTION SUCCESSFUL: field replacement playback successful

GuideAssert() ... ASSERTION SUCCESSFUL: close event successfully played back

Unit Testing

4 assertions: 4 successful; 0 failed

Remove(): Removes the current record (physically)

[ back to method list ]

Caution

The record is physically removed: once the file has been saved, there is NO possibility to get the record back.

Syntax

Remove()

Parameters

None

Return

(void)

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    // Remove all soft deleted records
    while( ! $oCursor->EOF() )
    {
        if ( $oCursor->IsDeleted() )
        {
            $oCursor->Remove();
        }
        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/contacts.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Map( 'Address'    ,'a' );
$oCursor->Map( 'First Name' ,'f' );
$oCursor->Map( 'Last Name'  ,'l' );

$oCursor->Create( 'Contacts',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Contact' );
    $oCursor->Replace( 'Address','Address #' . $i );
    $oCursor->Replace( '@order',$i );
}

echo LSUnitTesting::assert( $oCursor->Reccount() === 5                          ,
                            'ASSERTION SUCCESSFUL: records successfully added'  ,
                            'ASSERTION FAILURE: adding records failed'          ,
                            'GuideAssert' );
$oCursor->GoTop();
$oCursor->Remove();

echo LSUnitTesting::assert( $oCursor->Reccount() === 4                          ,
                            'ASSERTION SUCCESSFUL: record successfully removed' ,
                            'ASSERTION FAILURE: record removal failure'         ,
                            'GuideAssert' );

$szRecord = $oCursor->Record();
echo '<p>RECORD:<br />',htmlentities( $szRecord ),'</p>';
echo LSUnitTesting::assert( $oCursor->Field('@order') === (string) 1            ,
                            'ASSERTION SUCCESSFUL: record successfully removed' ,
                            'ASSERTION FAILURE: record removal failure'         ,
                            'GuideAssert' );

$oCursor->Save();

GuideAssert() ... ASSERTION SUCCESSFUL: records successfully added

GuideAssert() ... ASSERTION SUCCESSFUL: record successfully removed

RECORD:
<Contact order="1"> <a>Address #1</a> </Contact>

GuideAssert() ... ASSERTION SUCCESSFUL: record successfully removed

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

Eliminate(), Delete(), Eliminate()

Replace(): Replaces the value of a field with a new value

[ back to method list ]

Syntax

Replace( $szField,$xValue,$bCDATA )

Alias

Update()

Parameters
NameTypeDescription
$szField string Field to replace
$xValue mixed Value to set. String or array of strings. Value to assign to $szField
$bCDATA bool Put in a CDATA structure. Optional. Only valid for XML data type. false by default
Return

(bool) true if $szField value replaced with $xValue; false otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'whatever',$szFile );

    $oCursor->Append( 'Item' );
    $oCursor->Replace( '@id',SetID() );
    $oCursor->Replace( 'Name','John Doe' );

    $oCursor->Save();

    echo LSUnitTesting::assert( ! STR_Empty( $oCursor->Field( '@id' ) )                 ,
                                'ASSERTION SUCCESSFUL: \'@id\' field successfully set'  ,
                                'ASSERTION FAILURE: incorrect \'@id\' field set'        ,
                                'GuideAssert' );

    echo LSUnitTesting::assert( $oCursor->Field( 'Name' ) === 'John Doe'                    ,
                                'ASSERTION SUCCESSFUL: \'Name\' field successfully replaced',
                                'ASSERTION FAILURE: incorrect field replacement'            ,
                                'GuideAssert' );
    $oCursor->Close();
}

GuideAssert() ... ASSERTION SUCCESSFUL: '@id' field successfully set

GuideAssert() ... ASSERTION SUCCESSFUL: 'Name' field successfully replaced

Unit Testing

2 assertions: 2 successful; 0 failed

Requery(): Requeries the cursor

[ back to method list ]

Modified: 31/12/2012 14:33 Checking whether oDom not null

Syntax

Requery()

Parameters

None

Return

(void) no return provided

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

Save(): Saves the cursor physically

[ back to method list ]

Syntax

Save( $szFile )

Parameters
NameTypeDescription
$szFile string Optional. The name of the file the cursor must be saved to.
Return

(bool) true if the file was successfully saved; false otherwise.

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/events.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
}

$oCursor->Save();
$oCursor->Close();
$oCursor->Open();

echo LSUnitTesting::assert( $oCursor->FileExists()  &&
                            $oCursor->IsOpen()      &&
                            $oCursor->Reccount() === 5                          ,
                            'ASSERTION SUCCESSFUL: cursor saved successfully'   ,
                            'ASSERTION FAILURE: not the result we expected'     ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: cursor saved successfully

Unit Testing

1 assertions: 1 successful; 0 failed

Scatter(): Copies data from the current record to a DOMNode object

[ back to method list ]

Syntax

Scatter()

Parameters

None

Return

(DOMNode) DOMNode object or null if problem

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/tmp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
}

$oCursor->Go( 3 );
$oNode = $oCursor->Scatter();

echo LSUnitTesting::assert( (float) $oNode->GetAttribute( 'length' ) === 10.0   ,
                            'ASSERTION SUCCESSFUL: 10 is what we expected'      ,
                            'ASSERTION FAILURE: 10 is what we expected'         ,
                            'GuideAssert' );

$oCursor->GoBottom();
$oNode = $oCursor->Scatter();

echo LSUnitTesting::assert( (float) $oNode->GetAttribute( 'length' ) === 20.0   ,
                            'ASSERTION SUCCESSFUL: 20 is what we expected'      ,
                            'ASSERTION FAILURE: 20 is what we expected'         ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oNode->GetAttribute( 'unknown' ) === ''                ,
                            'ASSERTION SUCCESSFUL: empty string is what we expected',
                            'ASSERTION FAILURE: empty string is what we expected'   ,
                            'GuideAssert' );

$oCursor->Skip(); // Should reach EOF
$oNode = $oCursor->Scatter();

echo LSUnitTesting::assert( is_null( $oNode )                               ,
                            'ASSERTION SUCCESSFUL: null is what we expected',
                            'ASSERTION FAILURE: null is what we expected'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: 10 is what we expected

GuideAssert() ... ASSERTION SUCCESSFUL: 20 is what we expected

GuideAssert() ... ASSERTION SUCCESSFUL: empty string is what we expected

GuideAssert() ... ASSERTION SUCCESSFUL: null is what we expected

Unit Testing

4 assertions: 4 successful; 0 failed

Search(): Searches a value in each record (search starts where the cursor pointer is positioned - update with GoTop() if needed)

[ back to method list ]

Syntax

Search( $szValue,$IsSensitive,$szFnc )

Parameters
NameTypeDescription
$szValue string Value to look for
$IsSensitive boolean Case sensitive. Optional. true by default.
$szFnc string Callback function. Optional. null by default
Return

(boolean) true if $szValue found in any field of a record of the cursor. The record pointer is positioned where a match was found; false otherwise and cursor pointer unchanged (reset to where the search started).

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/somevalues.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );
$oCursor->Create( 'Events' );

$oCursor->Append( 'Event' );
$oCursor->Replace( '@name'  ,'11th anniversary' );
$oCursor->Replace( '@time'  ,'20140722000000' );
$oCursor->Replace( 'Body'   ,'Vae Soli! anniversary' );

$oCursor->Append( 'Event' );
$oCursor->Replace( '@name'  ,'Agile Tooling Fair' );
$oCursor->Replace( '@time'  ,'20140606090000' );
$oCursor->Replace( 'Body'   ,'Fair reserved to agile tooling: block the date!' );

$oCursor->Append( 'Event' );
$oCursor->Replace( '@name'  ,'Quitus "Zeus"' );
$oCursor->Replace( '@time'  ,'20140510100000' );
$oCursor->Replace( 'Body'   ,'Presentation of Quitus "Zeus", phase 1 of Quitus. Sort of fair' );

$oCursor->GoTop();
$szValue = 'Fair';
$bFound  = $oCursor->Search( $szValue );

echo LSUnitTesting::assert( $bFound && $oCursor->Recno() === 2                      ,
                            "ASSERTION SUCCESSFUL: '{$szValue}' successfully found" ,
                            "ASSERTION FAILURE: failed to locate '{$szValue}'"      ,
                            'GuideAssert' );

$oCursor->GoTop();
$oCursor->Search( $szValue,false );   // 1st instance
$oCursor->Skip(); // Go to next record
$bFound = $oCursor->Search( $szValue,false ); // 2nd instance

echo LSUnitTesting::assert( $bFound && $oCursor->Recno() === 3                                      ,
                            "ASSERTION SUCCESSFUL: '{$szValue}' successfully found (insensitive)"   ,
                            "ASSERTION FAILURE: failed to locate '{$szValue}'"                      ,
                            'GuideAssert' );

$szValue = 'anniversary';
$bFound  = $oCursor->Search( $szValue );

echo LSUnitTesting::assert( ! $bFound                                                       ,
                            "ASSERTION SUCCESSFUL: '{$szValue}' not located as expected"    ,
                            "ASSERTION FAILURE: failed to locate '{$szValue}'"              ,
                            'GuideAssert' );

$oCursor->GoTop();

$bFound  = $oCursor->Search( $szValue );

echo LSUnitTesting::assert( $bFound && $oCursor->Recno() === 1                                      ,
                            "ASSERTION SUCCESSFUL: '{$szValue}' located as expected (after GoTop())",
                            "ASSERTION FAILURE: failed to locate '{$szValue}'"                      ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: 'Fair' successfully found

GuideAssert() ... ASSERTION SUCCESSFUL: 'Fair' successfully found (insensitive)

GuideAssert() ... ASSERTION SUCCESSFUL: 'anniversary' not located as expected

GuideAssert() ... ASSERTION SUCCESSFUL: 'anniversary' located as expected (after GoTop())

Unit Testing

4 assertions: 4 successful; 0 failed

Seconds(): Keeps the 'SS' part of a 'HH:MM:SS' string

[ back to method list ]

Syntax

Seconds( $szTime )

Parameters
NameTypeDescription
$szTime string "HH:MM:SS" string
Return

(string) 'SS' of $szTime

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/calendar.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );

echo LSUnitTesting::assert( $oCursor->Seconds( '12:35:42' ) === '42',
                            'ASSERTION SUCCESSFUL: seconds correct' ,
                            'ASSERTION FAILURE: seconds incorrect'  ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: seconds correct

Unit Testing

1 assertions: 1 successful; 0 failed

Seek(): Seeks a value in a specific field (seek starts at where the cursor pointer is positioned - update with GoTop() if needed)

[ back to method list ]

Syntax

Seek( $szField,$szValue,$szFnc )

Parameters
NameTypeDescription
$szField string Field to look
$szValue string Value to look for
$szFnc string Callback function. Optional. null by default.
Return

(boolean) true if $szValue found in $szField and cursor pointer positioned; false otherwise and cursor pointer unchanged. cannot be determined

Example Executed
$szFile = 'c:\\WebSites\\ui.tl\\www\\databases\\uikey.xml';

$oCursor = new LSCursor( 'temp',$szFile );

if ( $oCursor->Open() )
{
    $bFound = $oCursor->Seek( 'K','KM-SMALL' );

    echo LSUnitTesting::assert( true                                                                ,
                                'ASSERTION SUCCESSFUL: Seek() has found \'KM-SMALL\' as expected'   ,
                                'ASSERTION FAILURE: Seek() has NOT found \'KM-SMALL\'. Weird!'      ,
                                'GuideAssert' );
}

GuideAssert() ... ASSERTION SUCCESSFUL: Seek() has found 'KM-SMALL' as expected

Unit Testing

1 assertions: 1 successful; 0 failed

SeekIndex(): Seek a value by taking advantage of the $szIDXFile index file.

[ back to method list ]

Caution

The Index() method must be used with caution. The key on which the index is to be created SHOULD be unique as the SeekIndex() method will always retrieve the first match. Therefore, having two keys with exactly the same value, may cause some trouble when trying to resolve duplicates (unless you take advantage of subsequent calls to Seek(), in which case you would imply call SeekIndex() to locate the first matching record and Seek() for the next ones)

Similarly setting a filter on the database/table influences the outcome of the Index() method as only the records matching the filter will be indexed.

Last but not least, ordering the table and then indexing may influence the result of the SeekIndex() method.

Our recommendation is to index unordered and unfiltered databases/tables unless you know exactly what you do.

Syntax

SeekIndex( $szValue,$szIDXFile )

Parameters
NameTypeDescription
$szValue string The value (unique key) we look for
$szIDXFile string Name of the index file that must be used. Optional. if $szIDXFile is not mentioned, the index that is used is the one that is named the same way as the original cursor with an .idx extension instead.
Return

(integer) In case of success, the method returns the matching record number; otherwise it returns -1

Example Executed
$szFile = 'c:\\WebSites\\ui.tl\\www\\databases\\uikey.xml';

$oCursor = new LSCursor( 'temp',$szFile );

if ( $oCursor->Open() )
{
    echo LSUnitTesting::assert( $oCursor->Index( 'K' )                              ,
                                'ASSERTION SUCCESSFUL: cursor indexed successfully' ,
                                'ASSERTION FAILURE: cursor could not be indexed'    ,
                                'GuideAssert' );

    $time1 = microtime(true);
    $iRecord = $oCursor->SeekIndex( 'KM-SMALL' );
    $time2 = microtime(true);

    echo LSUnitTesting::assert( ( $iRecord != -1 )                                  ,
                                'ASSERTION SUCCESSFUL: KM-SMALL found as expected'  ,
                                'ASSERTION FAILURE: KM-SMALL NOT found!'            ,
                                'GuideAssert' );
    echo "<p>KM-SMALL found in ",( $fTimeIdx = ( ( $time2 - $time1 ) * 1000 ) ),"ms at record #{$iRecord}</p>\n";

    $oCursor->GoTop();
    $time1 = microtime(true);

    if ( $oCursor->Seek( 'K','KM-SMALL' ) )
    {
        $time2 = microtime(true);
        echo "<p>KM-SMALL found in ",( $fTime = ( ( $time2 - $time1 ) * 1000 ) ),"ms at record #{$iRecord} with <code>Seek()</code></p>\n";
        echo LSUnitTesting::assert( ( $fTimeIdx < $fTime )                                                                  ,
                                    'ASSERTION SUCCESSFUL: SeekIndex() is faster than Seek() as expected'                   ,
                                    'ASSERTION FAILURE: Seek() is faster than SeekIndex(), which is not what we expected'   ,
                                    'GuideAssert' );
    }
}

GuideAssert() ... ASSERTION SUCCESSFUL: cursor indexed successfully

GuideAssert() ... ASSERTION SUCCESSFUL: KM-SMALL found as expected

KM-SMALL found in 0.65112113952637ms at record #6951

KM-SMALL found in 349.45511817932ms at record #6951 with Seek()

GuideAssert() ... ASSERTION SUCCESSFUL: SeekIndex() is faster than Seek() as expected

Unit Testing

3 assertions: 3 successful; 0 failed

Select(): Selects a fraction of the records of a given cursor

[ back to method list ]

Warning

Saving a record set can be dangerous by the fact that it may overwrite the physical source file mentioned in the FROM () clause of the SELECT statement

Remark

The first "(*)" clause of the $szStatement statement is completely disregarded at this time (02-05-14 10:21:50). The $szStatement statement MUST be very simple at this stage (for example, only 1 source data can be considered as of now)

Syntax

Select( $szStatement )

Parameters
NameTypeDescription
$szStatement string SELECT statement in the following form: "SELECT (*) FROM (*) WHERE (*)"
Return

(LSCursor) A record set in the form of a memory cursor

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

$oCursor->Create( 'Records',$szFile );
$oCursor->Append( 'Item' );
$oCursor->Replace( '@id','REF-1' );
$oCursor->Replace( 'Event','A new event will start on 20141231' );

$oCursor->Append( 'Item' );
$oCursor->Replace( '@id','REF-2' );
$oCursor->Replace( 'Event','Big fiesta 20150101' );

$oCursor->Save();

// Here select ONLY record 2
$oRecSet = $oCursor->Select( "SELECT (*) FROM ({$szFile}) WHERE (@id=\"REF-2\")" );

echo "<p>Records count: ",$oRecSet->Reccount(),"</p>";
echo "<p>Record pointer: ",$oRecSet->Recno(),"</p>";

echo htmlentities( $szXML = (string) $oRecSet );

echo LSUnitTesting::assert( STR_Pos( $szXML,'20150101' ) != -1  &&
                            STR_Pos( $szXML,'20141231' ) == -1  &&
                            $oRecSet->Recno() === 1             &&
                            $oRecSet->Reccount() === 1                  ,
                            'ASSERTION SUCCESSFUL: record set correct'  ,
                            'ASSERTION FAILURE: incorrect record set'   ,
                            'GuideAssert' );

// Here select ONLY record 1 and make sure it matches 2 clauses
$oRecSet = $oCursor->Select( "SELECT (*) FROM ({$szFile}) WHERE ( @id=\"REF-1\" and contains( Event,'will start' ) )" );
echo htmlentities( $szXML = (string) $oRecSet );

echo LSUnitTesting::assert( $oRecSet->Reccount() === 1                  ,
                            'ASSERTION SUCCESSFUL: record set correct'  ,
                            'ASSERTION FAILURE: incorrect record set'   ,
                            'GuideAssert' );

// Here the WHERE clause does not match any record
$oRecSet = $oCursor->Select( "SELECT (*) FROM ({$szFile}) WHERE ( @id=\"REF-1\" and contains( Event,'will NOT start' ) )" );
echo htmlentities( $szXML = (string) $oRecSet );

echo LSUnitTesting::assert( $oRecSet->Reccount() === -1                 ,
                            'ASSERTION SUCCESSFUL: record set correct'  ,
                            'ASSERTION FAILURE: incorrect record set'   ,
                            'GuideAssert' );

Records count: 1

Record pointer: 1

<?xml version="1.0"?> <Records> <Item id="REF-2"> <Event>Big fiesta 20150101</Event> </Item> </Records>

GuideAssert() ... ASSERTION SUCCESSFUL: record set correct

<?xml version="1.0"?> <Records> <Item id="REF-1"> <Event>A new event will start on 20141231</Event> </Item> </Records>

GuideAssert() ... ASSERTION SUCCESSFUL: record set correct

<?xml version="1.0"?> <Records/>

GuideAssert() ... ASSERTION SUCCESSFUL: record set correct

Unit Testing

3 assertions: 3 successful; 0 failed

SetFilter(): Applies a new filter on the data file

[ back to method list ]

Warning

This function does NOT do anything yet (02-09-13 13:26:42)

Syntax

SetFilter()

Parameters

None

Return

(void)

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

Skip(): Skips $n records

[ back to method list ]

Syntax

Skip( $n )

Parameters
NameTypeDescription
$n int Number of records to skip. 1 by default. $n can be negative to skip backward.
Return

(bool) true if $n skip OK; false otherwise

Example(s)
$szVaesoliDir = '/vaesoli/include';

require_once( "{$szVaesoliDir}/LSCursor.class.php"   );
require_once( "{$szVaesoliDir}/LSForm.class.php"     );
require_once( "{$szVaesoliDir}/LSGrid.class.php"     );
require_once( "{$szVaesoliDir}/LSDate.functions.php" );
require_once( "{$szVaesoliDir}/LSV.functions.php"    );

$szFile  = FIL_Normalize( FIL_ResolveRoot( "/DB/uad.xml" ) );
$oCursor = new LSCursor( "Data",$szFile );

if ( $oCursor->Open() )
{
    while( ! $oCursor->EOF() )
    {
        $szFirstName = trim( $oCursor->Field( 'FName' ) );
        $szLastName  = trim( $oCursor->Field( 'LName' ) );

        echo "<p>Record #",$oCursor->Recno(),trim( $szFirstName . ' ' . $szLastName ),"</p>\n";

        $oCursor->Skip();
    }
    $oCursor->Close();
}
else
{
    echo "<p>Cannot open cursor!</p>\n";
}
Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'temp',$szFile );

if ( ! is_file( $szFile ) )
{
    $oCursor->Create( 'Events',$szFile );

    for ( $i = 0;$i<5;$i++ )
    {
        $oCursor->Append( 'Event' );
    }

    $oCursor->GoTop();

    echo LSUnitTesting::assert( $oCursor->Recno() === 1 && $oCursor->Reccount() === 5               ,
                                'ASSERTION SUCCESSFUL: right record count and right record pointer' ,
                                'ASSERTION FAILURE: reccount() & recno() failure'                   ,
                                'GuideAssert' );

    while ( ! $oCursor->EOF() )
    {
        $oCursor->Skip();
    }

    // Still to do
    //echo LSUnitTesting::assert( $GLOBALS[ 'xDestructVar' ] === 'APPEND'             ,
    //                            'ASSERTION SUCCESSFUL: append playback successful'  ,
    //                            'ASSERTION FAILURE: append playback failure'        ,
    //                            'GuideAssert' );
}

GuideAssert() ... ASSERTION SUCCESSFUL: right record count and right record pointer

Unit Testing

1 assertions: 1 successful; 0 failed

Sort(): Sorts the cursor on a given field

[ back to method list ]

Syntax

Sort( $szField )

Parameters
NameTypeDescription
$szField string The field we need to sort the cursor on
Return

(void)

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

Stod(): Turns a YYYYMMDD[HHmmSS] date into a DD/MM/YYYY date

[ back to method list ]

Syntax

Stod( $szDate )

Parameters
NameTypeDescription
$szDate string "YYYYMMDD" or "YYYYMMDDHHmmSS" string
Return

(string) DD/MM/YYYY or null if incorrect

Example Executed
$oCursor = new LSCursor( 'Events' );

echo "<p>",$szDate1 = $oCursor->Stod( '20131231' ),"</p>";

echo LSUnitTesting::assert( $szDate1 === '31/12/2013'                   ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo "<p>",$szDate2 = $oCursor->Stod( '20131231235959' ),"</p>";

echo LSUnitTesting::assert( $szDate2 === '31/12/2013'                   ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo LSUnitTesting::assert( is_null( $oCursor->Stod('hello') )          ,
                            'ASSERTION SUCCESSFUL: result OK'           ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

31/12/2013

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

31/12/2013

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

Unit Testing

3 assertions: 3 successful; 0 failed

Stot(): Creates a time value (time()) from a YYYYMMDDHHmmSS string

[ back to method list ]

Syntax

Stot( $szDate,$szFormat )

Parameters
NameTypeDescription
$szDate string Time string (YYYYMM[DD[HH[mm[SS]]]])
$szFormat string Optional return format. 'd/m/Y H:i:s' by default
Return

(int) Time value of $szDate

Example Executed
$oCursor = new LSCursor( 'Events' );

echo LSUnitTesting::assert( $oCursor->Stot( '20140402075518' ) === '02/04/2014 07:55:18',
                            'ASSERTION SUCCESSFUL: result OK'                           ,
                            'ASSERTION FAILURE: not expected result'                    ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Stot( '20140402075518','Y' ) === '2014'           ,
                            'ASSERTION SUCCESSFUL: result OK'                           ,
                            'ASSERTION FAILURE: not expected result'                    ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oCursor->Stot( '20140402075518','H:i:s' ) === '07:55:18'   ,
                            'ASSERTION SUCCESSFUL: result OK'                           ,
                            'ASSERTION FAILURE: not expected result'                    ,
                            'GuideAssert' );
echo LSUnitTesting::assert( is_null( $oCursor->Stot( 'hello' ) )    ,
                            'ASSERTION SUCCESSFUL: result OK'       ,
                            'ASSERTION FAILURE: not expected result',
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

GuideAssert() ... ASSERTION SUCCESSFUL: result OK

Unit Testing

4 assertions: 4 successful; 0 failed

Sum(): Calculates the sum of a field

[ back to method list ]

Syntax

Sum( $szField )

Parameters
NameTypeDescription
$szField string Field whose sum must be calculated
Return

(float) The sum

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/average.xml';

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor = new LSCursor( 'Events',$szFile );
$oCursor->Create( 'Events',$szFile );

for ( $i=0;$i<5;$i++ )
{
    $oCursor->Append( 'Event' );
    $oCursor->Replace( '@length',$i * 5 );
}

$oCursor->Save();

echo $oCursor->Sum('@length');

echo LSUnitTesting::assert( $oCursor->Sum('@length') === 50.0   ,
                            'ASSERTION SUCCESSFUL: sum OK'      ,
                            'ASSERTION FAILURE: sum NOT OK'     ,
                            'GuideAssert' );

50

GuideAssert() ... ASSERTION SUCCESSFUL: sum OK

Unit Testing

1 assertions: 1 successful; 0 failed

Time(): Turns a YYYYMMDDHHmmSS date into a HH:mm[:SS] string

[ back to method list ]

Syntax

Time( $szDate )

Parameters
NameTypeDescription
$szDate string "YYYYMMDDHHmmSS"
Return

(string) HH:mm[:SS] string or null if incorrect

Example Executed
$oCursor = new LSCursor( 'Events' );

echo LSUnitTesting::assert( $oCursor->Time( '20140402075518' ) === '07:55:18'   ,
                            'ASSERTION SUCCESSFUL: result OK  (HH:MM:SS)'       ,
                            'ASSERTION FAILURE: not expected result'            ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '2014-04-02  07:55:18' ) === '07:55:18' ,
                            'ASSERTION SUCCESSFUL: result OK  (HH:MM:SS)'           ,
                            'ASSERTION FAILURE: not expected result'                ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '2014/04/02  07h55m18sec' ) === '07:55:18'  ,
                            'ASSERTION SUCCESSFUL: result OK  (HH:MM:SS)'               ,
                            'ASSERTION FAILURE: not expected result'                    ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '2014040207551' ) === '07:55'   ,
                            'ASSERTION SUCCESSFUL: result OK (HH:MM)'       ,
                            'ASSERTION FAILURE: not expected result'        ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '201404020755' ) === '07:55',
                            'ASSERTION SUCCESSFUL: result OK  (HH:MM)'  ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '20140402075' ) === '07:00' ,
                            'ASSERTION SUCCESSFUL: result OK (HH:MM)'   ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo LSUnitTesting::assert( $oCursor->Time( '2014040207' ) === '07:00'  ,
                            'ASSERTION SUCCESSFUL: result OK (HH:MM)'   ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

echo LSUnitTesting::assert( is_null( $oCursor->Time( '20140402' ) )     ,
                            'ASSERTION SUCCESSFUL: null result OK'      ,
                            'ASSERTION FAILURE: not expected result'    ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM:SS)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM:SS)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM:SS)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM)

GuideAssert() ... ASSERTION SUCCESSFUL: result OK (HH:MM)

GuideAssert() ... ASSERTION SUCCESSFUL: null result OK

Unit Testing

8 assertions: 8 successful; 0 failed

Toggle(): Toggle a field (true to false and vice versa

[ back to method list ]

Syntax

Toggle( $szField )

Parameters
NameTypeDescription
$szField string Field whose value must be inversed
Return

(string) 'true' if field toggled to true; 'false' otherwise

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/temp.xml';

$oCursor = new LSCursor( 'temp',$szFile );

if ( is_file( $szFile ) )
    FIL_Del( $szFile );

$oCursor->Create( 'Root' );
$oCursor->Append( 'Item' );

$oCursor->Replace( '@approved','true' );

echo LSUnitTesting::assert( $oCursor->Field( '@approved' ) === 'true'               ,
                            'ASSERTION SUCCESSFUL: @approved is set to "true"'      ,
                            'ASSERTION FAILURE:  @approved is NOT set to "true"'    ,
                            'GuideAssert' );

$oCursor->Toggle( '@approved' );

echo LSUnitTesting::assert( $oCursor->Field( '@approved' ) === 'false'               ,
                            'ASSERTION SUCCESSFUL: @approved is set to "false"'      ,
                            'ASSERTION FAILURE:  @approved is NOT set to "false"'    ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: @approved is set to "true"

GuideAssert() ... ASSERTION SUCCESSFUL: @approved is set to "false"

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

Change()

UserAgent(): Determines the User Agent of the visitor

[ back to method list ]

Syntax

UserAgent()

Parameters

None

Return

(string) UA of the visitor

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/tmp.xml';

$oCursor = new LSCursor( 'Events',$szFile );

echo "<p>",$oCursor->UserAgent(),"</p>";

Wget/1.9+cvs-dev-200404081407

Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

Value(): Returns the text value of the current record

[ back to method list ]

Warning

Fields which are stored as XML attributes are never returned by the Value() method

Syntax

Value()

Parameters

None

Return

(string) Value of the current record

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/somevalues.xml';

$oCursor = new LSCursor( 'Calendar',$szFile );
$oCursor->Create( 'Events' );

$oCursor->Append( 'Event' );
$oCursor->Replace( '@name','25th anniversary' );
$oCursor->Replace( '@time','20140402075518' );

echo LSUnitTesting::assert( STR_Empty( $oCursor->Value() )                      ,
                            'ASSERTION SUCCESSFUL: empty value as expected'     ,
                            'ASSERTION FAILURE: not an empty value as expected' ,
                            'GuideAssert' );

$oCursor->Replace( 'Body'       ,$szField1 = 'This is an event that will take the full day' );
$oCursor->Replace( 'Location'   ,$szField2 = 'Not defined yet' );

$szValue = $oCursor->Value();

echo LSUnitTesting::assert( STR_Pos( $szValue,$szField1 ) != -1 &&
                            STR_Pos( $szValue,$szField2 )                       ,
                            'ASSERTION SUCCESSFUL: I found my two fields back'  ,
                            'ASSERTION FAILURE: could not find my fields'       ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: empty value as expected

GuideAssert() ... ASSERTION SUCCESSFUL: I found my two fields back

Unit Testing

2 assertions: 2 successful; 0 failed

VisitorIP(): Determines the IP address of the visitor

[ back to method list ]

Syntax

VisitorIP()

Parameters

None

Return

(string) IP of the visitor

Example Executed
$szDir = __DIR__ . '/../tmp';
$szFile = $szDir . '/tmp.xml';

$oCursor = new LSCursor( 'Events',$szFile );

echo "<p>",$szIP = $oCursor->VisitorIP(),"</p>";

echo LSUnitTesting::assert( ! STR_Empty( $szIP )                    ,
                            'ASSERTION SUCCESSFUL: looks OK'        ,
                            'ASSERTION FAILURE: does not look OK'   ,
                            'GuideAssert' );

127.0.0.1

GuideAssert() ... ASSERTION SUCCESSFUL: looks OK

Unit Testing

1 assertions: 1 successful; 0 failed

Précédent Suivant