本文整理匯總了PHP中PHPWS_Text::sentence方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHPWS_Text::sentence方法的具體用法?PHP PHPWS_Text::sentence怎麽用?PHP PHPWS_Text::sentence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHPWS_Text
的用法示例。
在下文中一共展示了PHPWS_Text::sentence方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: import
/**
* Imports a SQL dump into the database.
* This function can not be called statically.
* @returns True if successful, false if not successful and report_errors = false or
* Error object if report_errors = true
*/
public static function import($text, $report_errors = true)
{
PHPWS_DB::touchDB();
// first_import makes sure at least one query was completed
// successfully
$first_import = false;
$sqlArray = PHPWS_Text::sentence($text);
$error = false;
foreach ($sqlArray as $sqlRow) {
if (empty($sqlRow) || preg_match("/^[^\\w\\d\\s\\(\\)]/i", $sqlRow)) {
continue;
}
$sqlCommand[] = $sqlRow;
if (preg_match("/;\$/", $sqlRow)) {
$query = implode(' ', $sqlCommand);
$sqlCommand = array();
if (!DB_ALLOW_TABLE_INDEX && preg_match('/^create index/i', $query)) {
continue;
}
PHPWS_DB::homogenize($query);
$result = PHPWS_DB::query($query);
if (DB::isError($result)) {
if ($report_errors) {
return $result;
} else {
PHPWS_Error::log($result);
$error = true;
}
}
$first_import = true;
}
}
if (!$first_import) {
if ($report_errors) {
return PHPWS_Error::get(PHPWS_DB_IMPORT_FAILED, 'core', 'PHPWS_DB::import');
} else {
PHPWS_Error::log(PHPWS_DB_IMPORT_FAILED, 'core', 'PHPWS_DB::import');
$error = true;
}
}
if ($error) {
return false;
} else {
return true;
}
}