Commit 0aac52ef authored by zYne's avatar zYne

--no commit message

--no commit message
parent 83d89b76
...@@ -133,10 +133,12 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -133,10 +133,12 @@ class Doctrine_Export extends Doctrine_Connection_Module
* *
* @return void * @return void
*/ */
public function createTable($name, array $fields, array $options = array()) { public function createTable($name, array $fields, array $options = array())
if ( ! $name) {
if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw new Doctrine_Export_Exception('no valid table name specified');
}
if (empty($fields)) { if (empty($fields)) {
throw new Doctrine_Export_Exception('no fields specified for table '.$name); throw new Doctrine_Export_Exception('no fields specified for table '.$name);
} }
...@@ -148,7 +150,7 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -148,7 +150,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$name = $this->conn->quoteIdentifier($name, true); $name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')'; $query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
print $query."<br \>";
return $this->conn->exec($query); return $this->conn->exec($query);
} }
/** /**
...@@ -653,7 +655,7 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -653,7 +655,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$this->createTable($table->getTableName(), $columns); $this->createTable($table->getTableName(), $columns);
} catch(Doctrine_Connection_Exception $e) { } catch(Doctrine_Connection_Exception $e) {
$reporter->add(E_ERROR, $e->getCode()); $reporter->add(E_ERROR, $e->getMessage());
} }
return $reporter; return $reporter;
......
...@@ -54,17 +54,22 @@ class Doctrine_Hook ...@@ -54,17 +54,22 @@ class Doctrine_Hook
*/ */
protected $params = array(); protected $params = array();
/** /**
* @var array $fieldParsers * @var array $fieldParsers custom field parsers array
* keys as field names in the format componentAlias.FieldName
* values as parser names / objects
*/ */
protected $fieldParsers = array(); protected $fieldParsers = array();
/** /**
* @var array $typeParsers * @var array $typeParsers type parsers array
* keys as type names and values as parser names / objects
*/ */
protected $typeParsers = array( protected $typeParsers = array(
'char' => 'Doctrine_Hook_WordLike', 'char' => 'Doctrine_Hook_WordLike',
'string' => 'Doctrine_Hook_WordLike', 'string' => 'Doctrine_Hook_WordLike',
'integer' => 'Doctrine_Hook_Integer', 'integer' => 'Doctrine_Hook_Integer',
'time' => 'Doctrine_Hook_Time',
'date' => 'Doctrine_Hook_Date',
); );
/** /**
...@@ -88,13 +93,25 @@ class Doctrine_Hook ...@@ -88,13 +93,25 @@ class Doctrine_Hook
{ {
return $this->query; return $this->query;
} }
public function leftJoin($dql) /**
* setTypeParser
*
* @param string $type type name
* @param string|object $parser parser name or custom parser object
*/
public function setTypeParser($type, $parser)
{ {
$this->typeParsers[$type] = $parser;
} }
public function innerJoin($dql) /**
* setFieldParser
*
* @param string $field field name
* @param string|object $parser parser name or custom parser object
*/
public function setFieldParser($field, $parser)
{ {
$this->fieldParsers[$field] = $parser;
} }
/** /**
* hookWhere * hookWhere
......
...@@ -58,33 +58,27 @@ abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser ...@@ -58,33 +58,27 @@ abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser
*/ */
public function parseClause($alias, $field, $value) public function parseClause($alias, $field, $value)
{ {
$parts = Doctrine_Query::bracketExplode($value, ' AND ', '(', ')'); $parts = Doctrine_Query::quoteExplode($value, ' AND ');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$part = Doctrine_Query::bracketTrim($part, '(', ')');
$ret[] = $this->parseSingle($alias, $field, $part); $ret[] = $this->parseSingle($alias, $field, $part);
} }
$r = implode(' AND ', $ret); $r = implode(' AND ', $ret);
} else { } else {
$parts = Doctrine_Query::bracketExplode($value, ' OR ', '(', ')'); $parts = Doctrine_Query::quoteExplode($value, ' OR ');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$part = Doctrine_Query::bracketTrim($part, '(', ')');
$ret[] = $this->parseClause($alias, $field, $part); $ret[] = $this->parseClause($alias, $field, $part);
} }
$r = implode(' OR ', $ret); $r = implode(' OR ', $ret);
} else { } else {
if (substr($parts[0],0,1) == '(' && substr($parts[0],-1) == ')') { $ret = $this->parseSingle($alias, $field, $parts[0]);
return $this->parseClause(substr($parts[0],1,-1)); return $ret;
} else {
$ret = $this->parseSingle($alias, $field, $parts[0]);
return $ret;
}
} }
} }
return '(' . $r . ')'; return '(' . $r . ')';
......
...@@ -46,12 +46,20 @@ class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex ...@@ -46,12 +46,20 @@ class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex
*/ */
public function parseSingle($alias, $field, $value) public function parseSingle($alias, $field, $value)
{ {
$e2 = explode(' ',$value); if (strpos($value, "'") !== false) {
$value = Doctrine_Query::bracketTrim($value, "'", "'");
$a[] = $alias . '.' . $field . ' LIKE ?';
$this->params[] = $value . '%';
foreach ($e2 as $v) { } else {
$v = trim($v); $e2 = explode(' ',$value);
$a[] = $alias. '.' . $field . ' LIKE ?';
$this->params[] = $v . '%'; foreach ($e2 as $v) {
$v = trim($v);
$a[] = $alias . '.' . $field . ' LIKE ?';
$this->params[] = $v . '%';
}
} }
return implode(' OR ', $a); return implode(' OR ', $a);
} }
......
...@@ -1023,8 +1023,6 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -1023,8 +1023,6 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
* parameters: * parameters:
* $str = email LIKE 'John@example.com' * $str = email LIKE 'John@example.com'
* $d = ' AND ' * $d = ' AND '
* $e1 = '('
* $e2 = ')'
* *
* would return an array: * would return an array:
* array("email", "LIKE", "'John@example.com'") * array("email", "LIKE", "'John@example.com'")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment