本文整理匯總了PHP中scraperwiki::unicode_truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP scraperwiki::unicode_truncate方法的具體用法?PHP scraperwiki::unicode_truncate怎麽用?PHP scraperwiki::unicode_truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scraperwiki
的用法示例。
在下文中一共展示了scraperwiki::unicode_truncate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save_sqlite
static function save_sqlite($unique_keys, $data, $table_name = "swdata", $verbose = 2)
{
$ds = SW_DataStoreClass::create();
if (count($data) == 0) {
return;
}
if (!array_key_exists(0, $data)) {
$data = array($data);
}
# convert special types
foreach ($data as &$row) {
foreach ($row as $key => &$value) {
if ($value instanceof DateTime) {
$new_value = clone $value;
$new_value->setTimezone(new DateTimeZone('UTC'));
$value = $new_value->format(DATE_ISO8601);
assert(strpos($value, "+0000") !== FALSE);
$value = str_replace("+0000", "", $value);
}
}
}
$result = $ds->request(array('maincommand' => 'save_sqlite', 'unique_keys' => $unique_keys, 'data' => $data, 'swdatatblname' => $table_name));
if (property_exists($result, 'error')) {
throw new Exception($result->error);
}
if ($verbose == 2) {
$sdata = $data[0];
$pdata = array();
foreach ($sdata as $key => $value) {
$pdata[scraperwiki::unicode_truncate($key, 50)] = scraperwiki::unicode_truncate($value, 50);
}
if (count($data) >= 2) {
$pdata["number_records"] = "Number Records: " . count($data);
}
scraperwiki::sw_dumpMessage(array('message_type' => 'data', 'content' => $pdata));
}
return $result;
}
示例2: save_sqlite
static function save_sqlite($unique_keys, $data, $table_name = "swdata", $verbose = 2)
{
$ds = SW_DataStoreClass::create();
$result = $ds->request(array('save_sqlite', $unique_keys, $data, $table_name));
if (property_exists($result, 'error')) {
throw new Exception($result->error);
}
if ($verbose == 2) {
if (array_key_exists(0, $data)) {
$sdata = $data[0];
} else {
$sdata = $data;
}
$pdata = array();
foreach ($sdata as $key => $value) {
$pdata[scraperwiki::unicode_truncate($key, 50)] = scraperwiki::unicode_truncate($value, 50);
}
if (array_key_exists(0, $data) && count($data) >= 2) {
$pdata["number_records"] = "Number Records: " . count($data);
}
scraperwiki::sw_dumpMessage(array('message_type' => 'data', 'content' => $pdata));
}
return $result;
}