Ejemplo n.º 1
0
 /**
  * Returns column definition from already existing table
  *
  * @param string $sql
  * @param string $column
  * @return array|null
  */
 protected function _getColumnDefinitionFromTable($table, $column)
 {
     $description = $this->_adapter->describeTable($table);
     if (!isset($description[$column])) {
         return null;
     }
     return array('type' => $this->_prepareIdentifier($description[$column]['DATA_TYPE']), 'unsigned' => (bool) $description[$column]['UNSIGNED']);
 }
Ejemplo n.º 2
0
 /**
  * Quote Table Row
  *
  * @param string $tableName
  * @param array $row
  * @return string
  */
 protected function _quoteRow($tableName, array $row)
 {
     $describe = $this->_read->describeTable($tableName);
     $rowData = array();
     foreach ($row as $k => $v) {
         if (is_null($v)) {
             $value = 'NULL';
         } elseif (in_array(strtolower($describe[$k]['DATA_TYPE']), array('bigint', 'mediumint', 'smallint', 'tinyint'))) {
             $value = $v;
         } else {
             $value = $this->_read->quoteInto('?', $v);
         }
         $rowData[] = $value;
     }
     return '(' . join(',', $rowData) . ')';
 }