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; }
$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>
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'));
/** * 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; } }