function createTableLike($name, $like, $defaults = false, $constraints = false, $idx = false, $tablespace = '')
{
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($name);
$this->fieldClean($like['schema']);
$this->fieldClean($like['table']);
$like = "\"{$like['schema']}\".\"{$like['table']}\"";
$status = $this->beginTransaction();
if ($status != 0) {
return -1;
}
$sql = "CREATE TABLE \"{$f_schema}\".\"{$name}\" (LIKE {$like}";
if ($defaults) {
$sql .= " INCLUDING DEFAULTS";
}
if ($this->hasCreateTableLikeWithConstraints() && $constraints) {
$sql .= " INCLUDING CONSTRAINTS";
}
if ($this->hasCreateTableLikeWithIndexes() && $idx) {
$sql .= " INCLUDING INDEXES";
}
$sql .= ")";
if ($this->hasTablespaces() && $tablespace != '') {
$this->fieldClean($tablespace);
$sql .= " TABLESPACE \"{$tablespace}\"";
}
$status = $this->execute($sql);
if ($status) {
$this->rollbackTransaction();
return -1;
}
return $this->endTransaction();
}