44 lines
1.1 KiB
PHP
Raw Normal View History

2013-07-19 18:52:52 +03:00
<?php
namespace OCA\Office;
class Op {
2013-07-20 18:56:09 +03:00
2013-08-07 13:04:32 +02:00
public static function add($esId, $op){
2013-08-07 00:48:43 +03:00
$query = \OCP\DB::prepare('INSERT INTO `*PREFIX*office_op` (`es_id`, `member`, `opspec`) VALUES (?, ?, ?) ');
2013-08-07 00:59:53 +03:00
$query->execute(array(
2013-08-07 13:04:32 +02:00
$esId,
2013-07-20 18:56:09 +03:00
$op['member'],
$op['opspec'],
));
2013-08-07 13:04:32 +02:00
// throw something - if query fails - thats fatal
return \OCP\DB::insertid(`*PREFIX*office_op`);
2013-08-06 18:07:05 +03:00
}
2013-08-07 13:04:32 +02:00
/**
* @returns "" when there are no Ops, or the seq of the last Op
*/
2013-08-06 18:07:05 +03:00
public static function getHeadSeq($esId){
$query = \OCP\DB::prepare('SELECT `seq` FROM `*PREFIX*office_op` WHERE `es_id`=? ORDER BY `seq` DESC LIMIT 1');
$result = $query->execute(array(
$esId
))
->fetchOne()
;
2013-08-07 13:04:32 +02:00
return is_null($result) ? "" : $result;
2013-08-06 18:07:05 +03:00
}
public static function getOpsAfter($esId, $seq){
2013-08-07 13:04:32 +02:00
if ($seq == "") $seq = -1;
$oplist = [];
$query = \OCP\DB::prepare('SELECT `opspec` FROM `*PREFIX*office_op` WHERE `es_id`=? AND `seq`>? ORDER BY `seq` ASC');
$result = $query->execute(array($esId, $seq));
while( $row = $result->fetchRow() ) {
$oplist[] = json_decode($row['opspec']);
}
return $oplist;
2013-07-20 18:56:09 +03:00
}
2013-07-19 18:52:52 +03:00
}