本文整理汇总了PHP中DBConnection::update方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::update方法的具体用法?PHP DBConnection::update怎么用?PHP DBConnection::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
static function update($id, $title, $content)
{
DBConnection::connect();
DBConnection::update('UPDATE post SET title = \'' . DBConnection::getCleanVar($title) . '\', content = \'' . DBConnection::getCleanVar($content) . '\' WHERE id = ' . DBConnection::getCleanVar($id));
return $id;
}
示例2: sizeof
$N = $sent[0];
$K = $sent[1];
$command = '/usr/bin/python /var/www/html/toyapp/toyapp-python/toyapp.py encrypt ' . $file_name . ' ' . $N . ' ' . $K;
echo $command;
//echo '<br />'.$command;
//echo '<br />';
#$result = #exec($command);#
$result = json_decode(exec($command, $status), true);
$size = sizeof($result);
//print_r($result);
$i = 0;
require_once '../includes/shareholdersapi.inc';
$shareholders = get_shareholders($sent[2]);
//print_r($shareholders);
require_once '../includes/DB_Abstraction.inc';
$db_con = new DBConnection();
$db_con->connect();
foreach ($result as $pair) {
$uid = $shareholders[$i]['uid'];
$db_con->insert('secrets', 'fid,uid,secret', "{$sent['2']},'{$uid}','[{$pair['0']},{$pair['1']}]'");
$i++;
echo "<br />Secret {$i}: <input type='text' readonly='readonly' value='[{$pair['0']},{$pair['1']}]'/>";
}
//print_r($result);//. ' <br />';
$db_con->update('file', "url='\\/toyapp\\/repo\\/{$fn}.enc',status=2", "fid={$sent['2']}");
$db_con->disconnect();
//unlink($file_name);
}
?>
</body>
</html>
示例3: array
echo '<p> All columns: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
echo '<p> Some columns: ';
var_dump($db->select('truck', array('brand', 'age'), 'id', $lastInsertedId));
echo '</p>';
/*
* SELECT ALL TEST.
*/
$db->insert('truck', array('brand' => 'Mercedes', 'age' => 3));
echo '<p> All rows and columns: ';
var_dump($db->select('truck', '*'));
/*
* UPDATE TEST.
*/
echo '<p> Before update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
$db->update('truck', array('vehicle_capacity' => 0, 'brand' => 'MAN', 'age' => 0), $lastInsertedId);
echo '<p> After update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
/*
* DELETE TEST.
*/
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId) . '</p>';
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId + 1) . '</p>';
/*
* GET TABLE COLUMNS NAMES TEST.
*/
var_dump($db->get_table_columns_names('truck'));
示例4: submit_changes
/**
* Update selected instance data of this type in the database. The instance
* data will not be changed, in case it remains with no data.
* Returns the number of affected rows on success.
* @return int|null
*/
public function submit_changes()
{
if ($this->id) {
$db = new DBConnection();
$dataToUpdate = array();
foreach ($this->classFields as $variable => $value) {
if ($value && $variable !== 'id') {
$dataToUpdate[$variable] = $value;
}
}
if (count($dataToUpdate)) {
return $db->update($this->convert_to_table_name($this->className), $dataToUpdate, $this->id);
} else {
return null;
}
} else {
return null;
}
}