本文整理汇总了PHP中DBManager::affected_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::affected_rows方法的具体用法?PHP DBManager::affected_rows怎么用?PHP DBManager::affected_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::affected_rows方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFeedbackFrom
function addFeedbackFrom($user, $value)
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineFeedbackColumns();
$table = Query::getDBSchema()->getTable(TABLE_FEEDBACK);
$db->execute($s = Query::generateInsertStm($table, array(FEEDBACK_CREATOR => $user->getID(), FEEDBACK_SUBJECT => $this->getID(), FEEDBACK_VALUE => $value ? 1 : 0)), $table->getName(), $this);
if ($db->affected_rows() != 1) {
$db->display_error("User::addFeedbackFrom()");
}
//Genera un errore ma ritorna comunque $this
} else {
$db->display_connect_error("User::addFeedbackFrom()");
}
return $this->loadFeedback();
}
示例2: createTag
/**
* Crea un tag.
* @param string $tag
* @return TRUE se il tag è stato creato, FALSE altrimenti.
*/
static function createTag($tag)
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineTagColumns();
$table = Query::getDBSchema()->getTable(TABLE_TAG);
$data = array(TAG_NAME => $tag);
$db->execute($s = Query::generateInsertStm($table, $data), $table->getName(), $tag);
if ($db->affected_rows() == 1) {
return true;
} else {
return false;
}
} else {
$db->display_connect_error("TagManager::createTag()");
}
}
示例3: getAccessCount
/**
* @deprecated
* Enter description here ...
* @param unknown_type $type
* @param unknown_type $id
*/
static function getAccessCount($type, $id)
{
if ($type == null || $type == "" || $id == null) {
return 0;
}
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineLogColumns();
$table = Query::getDBSchema()->getTable("AccessLog");
$exists = false;
if ($type == "Post") {
require_once 'post/PostManager.php';
return 0;
$exists = PostManager::postExists($id);
} else {
if ($type == "User") {
require_once 'user/UserManager.php';
return 0;
$exists = UserManager::userExists($id);
} elseif ($type == "Partner") {
//TODO: implementa Partner
// require_once 'post/PartnerManager.php';
// $exists = PartnerManager::partnerExists($id);
}
}
if ($exists) {
$wheres = array(new WhereConstraint($table->getColumn("alog_type"), Operator::EQUAL, $type), new WhereConstraint($table->getColumn("alog_id"), Operator::EQUAL, $id));
$db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, array()));
if ($db->num_rows() == 1) {
$row = $db->fetch_result();
$data = array("alog_count" => ++$row["alog_count"]);
$db->execute($s = Query::generateUpdateStm($table, $data, $wheres), null, LOGMANAGER);
if ($db->affected_rows() == 1) {
return $row["alog_count"];
}
} else {
$data = array("alog_type" => $type, "alog_id" => $id);
$db->execute($s = Query::generateInsertStm($table, $data));
if ($db->affected_rows() == 1) {
}
return 1;
}
}
return 0;
}
}
示例4: delete
function delete()
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineUserColumns();
$table = Query::getDBSchema()->getTable(TABLE_USER);
$rs = $db->execute($s = Query::generateDeleteStm($table, array(new WhereConstraint($table->getColumn(USER_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
//echo "<br />" . serialize($db->affected_rows()) . $s; //DEBUG
if ($db->affected_rows() == 1) {
return $this;
} else {
$db->display_error("User::delete()");
}
} else {
$db->display_connect_error("User::delete()");
}
return false;
}
示例5: explode
for ($i = 0; $i < count($queries); $i++) {
$db->execute($queries[$i], null, LOGMANAGER);
if ($db->result) {
$ss = explode("`", $queries[$i]);
echo "<p>TABLE " . $ss[1] . " INSTALLED</p>";
} else {
//DEBUG
$s = str_replace(",", ",<br />", $queries[$i]);
$s = str_replace(") ENGINE", ")<br />ENGINE", $s);
echo $s;
//DEBUG
echo $db->display_error("Install.php");
}
}
$db->execute("INSERT INTO `Role` VALUES('admin')", "Role", null);
$ra = $db->affected_rows();
$db->execute("INSERT INTO `Role` VALUES('user')", "Role", null);
$ra += $db->affected_rows();
if ($ra == 2) {
echo "<p>INSERTED ROLES</p>";
} else {
$db->display_error("Install.php");
}
// DEBUG
$db->execute("INSERT INTO `User` VALUES(1, 'ioesisto', 'no-reply@ioesisto.com', sha1('ciccia'), 'Io', 'Esisto', 'm', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', '2010-08-27 11:49:28', 1, 1)", "User", null);
if ($db->affected_rows() == 1) {
echo "<p>INSERTED FAKE USER</p>";
}
$db->execute("INSERT INTO `MailDirectory` VALUES(1, '" . TRASH . "', 1)", "MailDirectory", null);
$ra = $db->affected_rows();
$db->execute("INSERT INTO `MailDirectory` VALUES(2, '" . MAILBOX . "', 1)", "MailDirectory", null);
示例6: save
function save()
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineMailColumns();
$table = Query::getDBSchema()->getTable(TABLE_MAIL);
$data = array();
if (isset($this->subject) && !is_null($this->getSubject())) {
$data[MAIL_SUBJECT] = $this->getSubject();
}
if (isset($this->from) && !is_null($this->getFrom())) {
$data[MAIL_FROM] = intval($this->getFrom());
}
if (isset($this->to) && !is_null($this->getTo())) {
$data[MAIL_TO] = $this->getTo();
}
if (isset($this->text) && !is_null($this->getText())) {
$data[MAIL_TEXT] = $this->getText();
}
if (isset($this->repliesTo) && !is_null($this->getRepliesTo())) {
$data[MAIL_REPLIES_TO] = intval($this->getRepliesTo());
}
$rs = $db->execute($s = Query::generateInsertStm($table, $data), $table->getName(), $this);
//echo "<br />" . $s; //DEBUG
//echo "<br />" . $db->affected_rows(); //DEBUG
if ($db->affected_rows() == 1) {
$this->setID(intval($db->last_inserted_id()));
//echo "<br />" . serialize($this->ID); //DEBUG
$rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(MAIL_ID), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
//echo "<br />" . $s; //DEBUG
if ($db->num_rows() == 1) {
$row = $db->fetch_result();
$this->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[MAIL_CREATION_DATE])));
//echo "<br />" . serialize($row[MAIL_CREATION_DATE]); //DEBUG
//inserisce il messaggio nelle mailbox dei $to
$toes = explode("|", $this->getTo());
//echo serialize($toes); //DEBUG
require_once "mail/MailManager.php";
for ($i = 0; $i < count($toes); $i++) {
$dir = MailManager::loadDirectoryFromName(MAILBOX, intval($toes[$i]));
MailManager::addMailToDir($this, $dir);
}
//echo "<br />" . $this; //DEBUG
return $this;
} else {
$db->display_error("Mail::save()");
}
} else {
$db->display_error("Mail::save()");
}
} else {
$db->display_connect_error("Mail::save()");
}
return false;
}
示例7: addFollower
function addFollower($user)
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineFollowColumns();
$table = Query::getDBSchema()->getTable(TABLE_FOLLOW);
$db->execute($s = Query::generateInsertStm($table, array(FOLLOW_FOLLOWER => $user->getID(), FOLLOW_SUBJECT => $this->getID())), $table->getName(), $this);
if ($db->affected_rows() != 1) {
$db->display_error("User::addFollower()");
}
//Genera un errore ma ritorna comunque $this
} else {
$db->display_connect_error("User::addFollower()");
}
return $this->loadFollowers();
}
示例8: delete
function delete()
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineVoteColumns();
$table = Query::getDBSchema()->getTable(TABLE_VOTE);
$rs = $db->execute($s = Query::generateDeleteStm($table, array(new WhereConstraint($table->getColumn(VOTE_AUTHOR), Operator::EQUAL, $this->getAuthor()), new WhereConstraint($table->getColumn(VOTE_POST), Operator::EQUAL, $this->getPost()))), $table->getName(), $this);
//echo "<br />" . $s; //DEBUG
if ($db->affected_rows() == 1) {
return $this;
} else {
$db->display_error("Vote::delete()");
}
} else {
$db->display_connect_error("Vote::delete()");
}
return false;
}