예제 #1
0
 /**
  * Get the SQL syntax for a single column that would be included in a table create or alter statement.
  *
  * @param   SimpleXMLElement  $field  The XML field definition.
  *
  * @return  string
  *
  * @since   11.1
  */
 protected function getColumnSQL(SimpleXMLElement $field)
 {
     // Initialise variables.
     // TODO Incorporate into parent class and use $this.
     $blobs = array('text', 'smalltext', 'mediumtext', 'largetext');
     $fName = (string) $field['Field'];
     $fType = (string) $field['Type'];
     $fNull = (string) $field['Null'];
     $fKey = (string) $field['Key'];
     $fDefault = isset($field['Default']) ? (string) $field['Default'] : null;
     $fExtra = (string) $field['Extra'];
     $sql = $this->db->quoteName($fName) . ' ' . $fType;
     if ($fNull == 'NO') {
         if (in_array($fType, $blobs) || $fDefault === null) {
             $sql .= ' NOT NULL';
         } else {
             // TODO Don't quote numeric values.
             $sql .= ' NOT NULL DEFAULT ' . $this->db->quote($fDefault);
         }
     } else {
         if ($fDefault === null) {
             $sql .= ' DEFAULT NULL';
         } else {
             // TODO Don't quote numeric values.
             $sql .= ' DEFAULT ' . $this->db->quote($fDefault);
         }
     }
     if ($fExtra) {
         $sql .= ' ' . strtoupper($fExtra);
     }
     return $sql;
 }
예제 #2
0
 /**
  * Build where like conditions from strings with spaces
  * @param string $value
  * @param string $fieldName
  * @return string
  */
 protected function _buildLikeBySpaces($value, $fieldName)
 {
     $values = $this->_separateValue($value);
     foreach ($values as $key => $value) {
         $values[$key] = $this->_db->quote('%' . $value . '%');
     }
     return '(' . $fieldName . ' LIKE ' . implode(' AND ' . $fieldName . ' LIKE ', $values) . ' )';
 }
예제 #3
0
 /**
  * Test loadRowList method
  *
  * @return  void
  *
  * @since   11.4
  */
 public function testLoadRowList()
 {
     $query = $this->object->getQuery(true);
     $query->select('*');
     $query->from('jos_dbtest');
     $query->where('description=' . $this->object->quote('one'));
     $this->object->setQuery($query);
     $result = $this->object->loadRowList();
     $expected = array(array(1, 'Testing', '1980-04-18 00:00:00', 'one'), array(2, 'Testing2', '1980-04-18 00:00:00', 'one'));
     $this->assertThat($result, $this->equalTo($expected), __LINE__);
 }