32 'bignumber' =>
'bigint',
34 'varchar' =>
'varchar',
37 'bigtext' =>
'longtext',
38 'date' =>
'varchar(14)',
79 exit(
'XE cannot connect to DB.');
84 $this->
setError(mysql_errno(), mysql_error());
88 if(version_compare(mysql_get_server_info(
$result),
'4.1',
'<'))
90 $this->
setError(-1,
'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info());
97 $this->
setError(mysql_errno(), mysql_error());
134 if(version_compare(PHP_VERSION,
"5.4.0",
"<") && get_magic_quotes_gpc())
136 $string = stripslashes(str_replace(
"\\",
"\\\\", $string));
138 if(!is_numeric($string))
140 $string = @mysql_real_escape_string($string);
186 exit(
'XE cannot handle DB connection.');
214 if($arrayIndexEndValue)
216 $output[$arrayIndexEndValue--] = $tmp;
225 if(isset($arrayIndexEndValue))
245 $query = sprintf(
"insert into `%ssequence` (seq) values ('0')", $this->prefix);
248 if($sequence % 10000 == 0)
250 $query = sprintf(
"delete from `%ssequence` where seq < %d", $this->prefix, $sequence);
265 $query = sprintf(
"select password('%s') as password, old_password('%s') as old_password", $this->
addQuotes($password), $this->
addQuotes($password));
268 if($tmp->password === $saved_password || $tmp->old_password === $saved_password)
282 $query = sprintf(
"show tables like '%s%s'", $this->prefix, $this->
addQuotes($target_name));
302 function addColumn($table_name, $column_name, $type =
'number', $size =
'', $default = null, $notnull =
false)
304 $type = $this->column_type[$type];
305 if(strtoupper($type) ==
'INTEGER')
310 $query = sprintf(
"alter table `%s%s` add `%s` ", $this->prefix, $table_name, $column_name);
313 $query .= sprintf(
" %s(%s) ", $type, $size);
317 $query .= sprintf(
" %s ", $type);
321 $query .= sprintf(
" default '%s' ", $default);
339 $query = sprintf(
"alter table `%s%s` drop `%s` ", $this->prefix, $table_name, $column_name);
351 $query = sprintf(
"show fields from `%s%s`", $this->prefix, $table_name);
360 $column_name = strtolower($column_name);
361 foreach(
$output as $key => $val)
363 $name = strtolower($val->Field);
364 if($column_name == $name)
383 function addIndex($table_name, $index_name, $target_columns, $is_unique =
false)
385 if(!is_array($target_columns))
387 $target_columns = array($target_columns);
390 $query = sprintf(
"alter table `%s%s` add %s index `%s` (%s);", $this->prefix, $table_name, $is_unique ?
'unique' :
'', $index_name, implode(
',', $target_columns));
401 function dropIndex($table_name, $index_name, $is_unique =
false)
403 $query = sprintf(
"alter table `%s%s` drop index `%s`", $this->prefix, $table_name, $index_name);
416 $query = sprintf(
"show indexes from `%s%s`", $this->prefix, $table_name);
432 for($i = 0; $i < count(
$output); $i++)
434 if(
$output[$i]->Key_name == $index_name)
459 if(!file_exists($file_name))
481 $xml_obj = $oXml->parse($xml_doc);
483 $table_name = $xml_obj->table->attrs->name;
488 $table_name = $this->prefix . $table_name;
490 if(!is_array($xml_obj->table->column))
492 $columns[] = $xml_obj->table->column;
496 $columns = $xml_obj->table->column;
499 $primary_list = array();
500 $unique_list = array();
501 $index_list = array();
503 foreach($columns as $column)
505 $name = $column->attrs->name;
506 $type = $column->attrs->type;
507 $size = $column->attrs->size;
508 $notnull = $column->attrs->notnull;
509 $primary_key = $column->attrs->primary_key;
510 $index = $column->attrs->index;
511 $unique = $column->attrs->unique;
512 $default = $column->attrs->default;
513 $auto_increment = $column->attrs->auto_increment;
515 $column_schema[] = sprintf(
'`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ?
'(' . $size .
')' :
'', isset($default) ?
"default '" . $default .
"'" :
'', $notnull ?
'not null' :
'', $auto_increment ?
'auto_increment' :
'');
519 $primary_list[] = $name;
523 $unique_list[$unique][] = $name;
527 $index_list[$index][] = $name;
531 if(count($primary_list))
533 $column_schema[] = sprintf(
"primary key (%s)",
'`' . implode($primary_list,
'`,`') .
'`');
536 if(count($unique_list))
538 foreach($unique_list as $key => $val)
540 $column_schema[] = sprintf(
"unique %s (%s)", $key,
'`' . implode($val,
'`,`') .
'`');
544 if(count($index_list))
546 foreach($index_list as $key => $val)
548 $column_schema[] = sprintf(
"index %s (%s)", $key,
'`' . implode($val,
'`,`') .
'`');
552 $schema = sprintf(
'create table `%s` (%s%s) %s;', $this->
addQuotes($table_name),
"\n", implode($column_schema,
",\n"),
"ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci");
568 $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(
' ' . $this->comment_syntax, $this->query_id) :
'';
569 if(is_a(
$query,
'BaseObject'))
585 if(is_a(
$query,
'BaseObject'))
591 $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(
' ' . $this->comment_syntax, $this->query_id) :
'';
606 $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(
' ' . $this->comment_syntax, $this->query_id) :
'';
607 if(is_a(
$query,
'BaseObject'))
625 $limit = $queryObject->getLimit();
627 if($limit && $limit->isPageHandler())
634 if(is_a(
$query,
'BaseObject'))
638 $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(
' ' . $this->comment_syntax, $queryObject->queryID) :
'';
650 if($queryObject->usesClickCount())
679 return mysql_fetch_object(
$result);
689 return mysql_free_result(
$result);
699 $dbParser =
new DBParser(
'`',
'`', $this->prefix);
710 $limit = $queryObject->getLimit();
711 if($limit && $limit->isPageHandler())
714 $buff->total_count = 0;
715 $buff->total_page = 0;
717 $buff->data = array();
718 $buff->page_navigation =
new PageHandler(0, 1, 1, 10);
737 $limit = $queryObject->getLimit();
739 $temp_where = $queryObject->getWhereString($with_values,
false);
740 $count_query = sprintf(
'select count(*) as "count" %s %s',
'FROM ' . $queryObject->getFromString($with_values), ($temp_where ===
'' ?
'' :
' WHERE ' . $temp_where));
743 $temp_select = $queryObject->getSelectString($with_values);
744 $uses_distinct = stripos($temp_select,
"distinct") !==
false;
745 $uses_groupby = $queryObject->getGroupByString() !=
'';
746 if($uses_distinct || $uses_groupby)
748 $count_query = sprintf(
'select %s %s %s %s'
749 , $temp_select ==
'*' ?
'1' : $temp_select
750 ,
'FROM ' . $queryObject->getFromString($with_values)
751 , ($temp_where ===
'' ?
'' :
' WHERE ' . $temp_where)
752 , ($uses_groupby ?
' GROUP BY ' . $queryObject->getGroupByString() :
'')
756 $count_query = sprintf(
'select count(*) as "count" from (%s) xet', $count_query);
759 $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(
' ' . $this->comment_syntax, $queryObject->queryID) :
'';
761 $count_output = $this->
_fetch($result_count);
762 $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL);
764 $list_count = $limit->list_count->getValue();
769 $page_count = $limit->page_count->getValue();
774 $page = $limit->page->getValue();
775 if(!$page || $page < 1)
783 $total_page = (int) (($total_count - 1) / $list_count) + 1;
791 if($page > $total_page)
795 $buff->total_count = $total_count;
796 $buff->total_page = $total_page;
798 $buff->data = array();
799 $buff->page_navigation =
new PageHandler($total_count, $total_page, $page, $page_count);
802 $start_count = ($page - 1) * $list_count;
806 $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(
' ' . $this->comment_syntax, $this->query_id) :
'';
813 $virtual_no = $total_count - ($page - 1) * $list_count;
817 $buff->total_count = $total_count;
818 $buff->total_page = $total_page;
821 $buff->page_navigation =
new PageHandler($total_count, $total_page, $page, $page_count);
835 $select =
$query->getSelectString($with_values);
840 $select =
'SELECT ' . $select;
842 $from =
$query->getFromString($with_values);
847 $from =
' FROM ' . $from;
849 $where =
$query->getWhereString($with_values);
852 $where =
' WHERE ' . $where;
855 $groupBy =
$query->getGroupByString();
858 $groupBy =
' GROUP BY ' . $groupBy;
861 $orderBy =
$query->getOrderByString();
864 $orderBy =
' ORDER BY ' . $orderBy;
867 $limit =
$query->getLimitString();
870 $limit = sprintf(
' LIMIT %d, %d', $start_count, $list_count);
873 return $select .
' ' . $from .
' ' . $where .
' ' . $groupBy .
' ' . $orderBy .
' ' . $limit;
setError($errno=0, $errstr= 'success')
_executeDeleteAct($queryObject, $with_values=true)
getUpdateSql($query, $with_values=TRUE, $with_priority=FALSE)
getClickCountQuery($queryObject)
_rollback($transactionLevel=0)
getInsertSql($query, $with_values=TRUE, $with_priority=FALSE)
_executeInsertAct($queryObject, $with_values=true)
__query($query, $connection)
isConnected($type= 'master', $indx=0)
isValidOldPassword($password, $saved_password)
addIndex($table_name, $index_name, $target_columns, $is_unique=false)
_begin($transactionLevel=0)
queryPageLimit($queryObject, $result, $connection, $with_values=true)
getDeleteSql($query, $with_values=TRUE, $with_priority=FALSE)
& getParser($force=FALSE)
_afterConnect($connection)
isColumnExists($table_name, $column_name)
addColumn($table_name, $column_name, $type= 'number', $size= '', $default=null, $notnull=false)
__construct($auto_connect=TRUE)
getSelectPageSql($query, $with_values=true, $start_count=0, $list_count=0)
_executeSelectAct($queryObject, $connection=null, $with_values=true)
_connect($type= 'master', $indx=0)
_getConnection($type= 'master', $indx=NULL)
getSelectSql($query, $with_values=TRUE)
_query($query, $connection=NULL)
_fetch($result, $arrayIndexEndValue=NULL)
createTableByXmlFile($file_name)
db_fetch_object(&$result)
createTableByXml($xml_doc)
isTableExists($target_name)
dropColumn($table_name, $column_name)
_executeUpdateAct($queryObject, $with_values=true)
dropIndex($table_name, $index_name, $is_unique=false)
isIndexExists($table_name, $index_name)