}
} else {
- print_error('typenotimplement');
+ throw new dml_exception('typenotimplement');
}
return array($sql, $params);
}
}
if ($dollar_count) {
if ($count) {
- print_error('mixedtypesqlparam');
+ throw new dml_exception('mixedtypesqlparam');
}
$type = SQL_PARAMS_DOLLAR;
$count = $dollar_count;
}
if ($q_count) {
if ($count) {
- print_error('mixedtypesqlparam');
+ throw new dml_exception('mixedtypesqlparam');
}
$type = SQL_PARAMS_QM;
$count = $q_count;
}
if ($count > count($params)) {
- print_error('invalidqueryparam');
+ throw new dml_exception('invalidqueryparam');
}
if ($type & $allowed_types) { // bitwise AND
foreach ($named_matches[0] as $key) {
$key = trim($key, ':');
if (!array_key_exists($key, $params)) {
- print_error('missingkeyinsql', '', '', $key);
+ throw new dml_exception('missingkeyinsql', '', '', $key);
}
$finalparams[$key] = $params[$key];
}
if ($count != count($finalparams)) {
- print_error('duplicateparaminsql');
+ throw new dml_exception('duplicateparaminsql');
}
if ($target_type & SQL_PARAMS_QM) {
} else if ($target_type & SQL_PARAMS_NAMED) {
return array($sql, $finalparams, SQL_PARAMS_NAMED);
} else { // $type & SQL_PARAMS_DOLLAR
- print_error('boundsyntaxnotsupport');
+ throw new dml_exception('boundsyntaxnotsupport');
}
} else if ($type == SQL_PARAMS_DOLLAR) {
- print_error('boundsyntaxnotsupport');
+ throw new dml_exception('boundsyntaxnotsupport');
} else { // $type == SQL_PARAMS_QM
if (count($params) != $count) {
}
return array($sql, $finalparams, SQL_PARAMS_NAMED);
} else { // $type & SQL_PARAMS_DOLLAR
- print_error('boundsyntaxnotsupport');
+ throw new dml_exception('boundsyntaxnotsupport');
}
}
}
$params = array();
foreach ($conditions as $key=>$value) {
if (is_int($key)) {
- print_error('invalidnumkey');
+ throw new dml_exception('invalidnumkey');
}
if (is_null($value)) {
$where[] = "$key IS NULL";
public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
if ($prefix == '' and !$this->external) {
//Enforce prefixes for everybody but mysql
- print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+ throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
}
return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
}
public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
if ($prefix == '' and !$this->external) {
//Enforce prefixes for everybody but mysql
- print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+ throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
}
if (!$this->external and strlen($prefix) > 2) {
//Max prefix length for Oracle is 2cc
$a = (object)array('dbfamily'=>'oracle', 'maxlength'=>2);
- print_error('prefixtoolong', 'error', '', $a);
+ throw new dml_exception('prefixtoolong', $a);
}
return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
}
public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
if ($prefix == '' and !$this->external) {
//Enforce prefixes for everybody but mysql
- print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+ throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
}
return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
}