/**
  * Creates one new XMLDBStatement
  */
 function XMLDBStatement($name)
 {
     parent::XMLDBObject($name);
     $this->table = NULL;
     $this->type = XMLDB_STATEMENT_INCORRECT;
     $this->sentences = array();
 }
 /**
  * Creates one new XMLDBTable
  */
 function XMLDBTable($name)
 {
     parent::XMLDBObject($name);
     $this->fields = array();
     $this->keys = array();
     $this->indexes = array();
 }
 /**
  * Creates one new XMLDBStructure
  */
 function XMLDBStructure($name)
 {
     parent::XMLDBObject($name);
     $this->path = NULL;
     $this->version = NULL;
     $this->tables = array();
     $this->statements = array();
 }
 /**
  * Creates one new XMLDBKey
  */
 function XMLDBKey($name)
 {
     parent::XMLDBObject($name);
     $this->type = NULL;
     $this->fields = array();
     $this->reftable = NULL;
     $this->reffields = array();
 }
Example #5
0
 /**
  * Creates one new XMLDBField
  */
 function XMLDBField($name)
 {
     parent::XMLDBObject($name);
     $this->type = NULL;
     $this->length = NULL;
     $this->unsigned = false;
     $this->notnull = false;
     $this->default = NULL;
     $this->sequence = false;
     $this->enum = false;
     $this->enumvalues = NULL;
     $this->decimals = NULL;
 }
 /**
  * Creates one new XMLDBIndex
  */
 function XMLDBIndex($name)
 {
     parent::XMLDBObject($name);
     $this->unique = false;
     $this->fields = array();
 }
 /**
  * Given one XMLDB Statement, build the needed SQL insert sentences to execute it
  */
 function getExecuteInsertSQL($statement)
 {
     $results = array();
     //Array where all the sentences will be stored
     if ($sentences = $statement->getSentences()) {
         foreach ($sentences as $sentence) {
             /// Get the list of fields
             $fields = $statement->getFieldsFromInsertSentence($sentence);
             /// Get the values of fields
             $values = $statement->getValuesFromInsertSentence($sentence);
             /// Look if we have some CONCAT value and transform it dinamically
             foreach ($values as $key => $value) {
                 /// Trim single quotes
                 $value = trim($value, "'");
                 if (stristr($value, 'CONCAT') !== false) {
                     /// Look for data between parentesis
                     preg_match("/CONCAT\\s*\\((.*)\\)\$/is", trim($value), $matches);
                     if (isset($matches[1])) {
                         $part = $matches[1];
                         /// Convert the comma separated string to an array
                         $arr = XMLDBObject::comma2array($part);
                         if ($arr) {
                             $value = $this->getConcatSQL($arr);
                         }
                     }
                 }
                 /// Values to be sent to DB must be properly escaped
                 $value = addslashes($value);
                 /// Back trimmed quotes
                 $value = "'" . $value . "'";
                 /// Back to the array
                 $values[$key] = $value;
             }
             /// Iterate over fields, escaping them if necessary
             foreach ($fields as $key => $field) {
                 $fields[$key] = $this->getEncQuoted($field);
             }
             /// Build the final SQL sentence and add it to the array of results
             $sql = 'INSERT INTO ' . $this->getEncQuoted($this->prefix . $statement->getTable()) . '(' . implode(', ', $fields) . ') ' . 'VALUES (' . implode(', ', $values) . ')';
             $results[] = $sql;
         }
     }
     return $results;
 }
 /**
  * Constructor of the XMLDBFile
  */
 function XMLDBFile($path)
 {
     parent::XMLDBObject($path);
     $this->path = $path;
     $this->xmldb_structure = NULL;
 }