256 Part II: Developing Intranet Solutions Sets (Com web hosting)
256 Part II: Developing Intranet Solutions Sets an object variable called fields, which holds a comma separated list of fields from the std_fields set earlier. Sets the object variable dbi to point to the class.DBI.php-provided object, which is passed to the constructor by an application. The dbi member variable holds the DBI object that is used to communicate with the back-end database. Calls setDocID()to set the document ID of the object. Sets an object variable called std_fields, which is an array that contains the LD_DOCUMENT table attributes and their data type. . loadDocInfo(): This method loads all attribute values into the document object from the LD_DOCUMENT table by the specified document ID. This is how it works: setDocID() is called to set the passed document ID to the current object. If no document ID is passed, the current object s document ID is taken. The $this->dbi object is used to retrieve all the attribute values of the given document from the LD_DOCUMENT table. Each of the values is set to the current object so that they can be retrieved at any time using the other get methods of this class. For example $this->DOC_NAME is set the value of the DOC_NAME of the given document. This method sets all the attributes such as document ID, category number, heading, body of the document, and publish date for a given document. . addDoc(): This method adds new documents to the database. Attributes such as document ID, category number, heading, body of the document, and publish date are passed in an associative array as parameters to this method. It works as follows: The SQL statement is prepared using the $this->std_fields array that contains all the attributes of the LD_DOCUMENT table and the values from the associative array that has been passed as parameter. The values of the parameter are formatted using the quote() method of the $this->dbi object. After executing the SQL statement, the newly added document s DOC_ID is retrieved using another SQL statement. If the insertion query is successful, this method returns the category ID of the newly added category. Otherwise, it returns FALSE.