本文整理汇总了PHP中SQLQuery::addItemsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::addItemsArray方法的具体用法?PHP SQLQuery::addItemsArray怎么用?PHP SQLQuery::addItemsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::addItemsArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
if (count($fullname) > 0) { $fname = $fullname[0]; }
if (count($fullname) > 1) { $lname = $fullname[1]; }
$dataInsert['tw_id'] = $content->id;
$dataInsert['fname'] = $fname;
$dataInsert['lname'] = $lname;
$dataInsert['tw_name'] = $content->screen_name;
$dataInsert['avatar'] = $content->profile_image_url;
$dataInsert['tw_oauth_token'] = $access_token['oauth_token'];
$dataInsert['tw_oauth_token_secret'] = $access_token['oauth_token_secret'];
$user = $DB->selectWhatWhere("*", "tw_id = " . $content->id);
$update_success = 0;
$user_id = 0;
if (empty($user)) {
$update_success = $DB->addItemsArray($dataInsert);
$user_id = $DB->getLastId();
} else {
$user_id = $user[0]["users"]["id"];
$update_success = $DB->updateWhatWhereArray2($dataInsert, "id = " . $user_id);
}
if ($update_success == 0) {
$_SESSION['status'] = 'error';
} else {
$_SESSION['user_id'] = $user_id;
$_SESSION['twitter_uid'] = $content->id;
}
header('Location: ./index.php');
} else {
header('Location: ./clearsessions.php');
}
示例2: fopen
<?php
$filename = "songs.json";
include('lib/config.php');
include('lib/sqlquery.php');
// get contents of a file into a string
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
if ($contents) {
$songs = json_decode($contents, true);
if (array_key_exists('songs', $songs) and is_array($songs['songs'])) {
$DB = new SQLQuery();
$DB->chooseTable(DB_SONGS_TABLE);
foreach($songs['songs'] as $song) {
$dataInsert = array();
$dataInsert['id'] = $song['id'];
$dataInsert['title'] = $song['title'];
$dataInsert['artist'] = $song['artist'];
$dataInsert['album'] = $song['album'];
$dataInsert['length'] = $song['length'];
$dataInsert['filename'] = $song['filename'];
$DB->addItemsArray($dataInsert);
echo "Added " . $song['title'] . " by " . $song['artist'] . " to the database.<br />";
}
}
}
?>