コード例 #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
 /**
  * Test loadRowList method
  *
  * @return  void
  *
  * @since   11.1
  */
 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__);
 }
コード例 #3
0
ファイル: documents.php プロジェクト: abdullah929/bulletin
 /**
  * Prepare string array to using in SQL query.
  * Walk array and remove empty strings.
  * Non empty string escape and quote.
  *
  * @param array $items
  * @param boolean $search use for search, add % at begin and the end of item
  * @return array
  */
 public function getQuotedArray($items, $search = false)
 {
     $mark = $search ? '%' : '';
     foreach ($items as $i => $item) {
         $item = JString::trim($item);
         if ($item) {
             $items[$i] = $this->_db->quote($mark . $item . $mark);
         } else {
             unset($items[$i]);
         }
     }
     // reindexing
     $items = array_merge($items);
     return $items;
 }