예제 #1
0
 public function store()
 {
     $page_name = $this->name;
     // cleanups to make directory transversal impossible
     // TODO proper cleanup of name!
     $page_name = str_replace('.', '_', $page_name);
     $page_name = str_replace('/', '_', $page_name);
     $page_name = str_replace('\\', '_', $page_name);
     $page_name = str_replace(' ', '_', $page_name);
     $dst_file = WikiConfig::getDiskPath() . '/' . $page_name;
     file_put_contents($dst_file, $this->text);
     return SqlObject::store($this, self::$tbl_name, 'name');
 }
예제 #2
0
 function __construct($id)
 {
     parent::__construct("ticketTypes", "ticketTypeID", $id);
 }
예제 #3
0
 public function store()
 {
     return SqlObject::storeUnique($this, self::$tbl_name);
 }
예제 #4
0
 function __construct()
 {
     parent::__construct("wannabeCrewResponse", null, -1);
 }
예제 #5
0
 public static function getNewUsers($limit = 10)
 {
     $q = 'SELECT * FROM ' . self::$tbl_name . ' ORDER BY time_created DESC LIMIT ' . intval($limit);
     $list = Sql::pSelect($q);
     return SqlObject::loadObjects($list, 'User');
 }
예제 #6
0
 function __construct($ID)
 {
     parent::__construct("wannabeResponse", "ID", $ID);
 }
예제 #7
0
 public static function delete($id)
 {
     return SqlObject::deleteById($id, self::$tbl_name, 'id');
 }
예제 #8
0
 function __construct($articleID = -1)
 {
     parent::__construct("news", "ID", $articleID);
 }
예제 #9
0
 public static function remove($id)
 {
     return SqlObject::deleteById($id, self::$tbl_name);
 }
예제 #10
0
 /**
  * Question constructor.
  * 
  * @param int $questionID
  */
 public function __construct($questionID)
 {
     parent::__construct("wannabeQuestions", "ID", $questionID);
     $this->_responses = null;
 }
예제 #11
0
 public static function getAllByOwner($id)
 {
     $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ?';
     $list = Sql::pSelect($q, 'i', $id);
     return SqlObject::loadObjects($list, __CLASS__);
 }
예제 #12
0
 static function getActivePolls($type, $owner = 0)
 {
     $q = 'SELECT * FROM tblPolls' . ' WHERE type = ? AND owner = ? AND deleted_by = ? AND NOW() BETWEEN time_start AND time_end' . ' ORDER BY time_start ASC,text ASC';
     $list = Sql::pSelect($q, 'iii', $type, $owner, 0);
     return SqlObject::loadObjects($list, __CLASS__);
 }
예제 #13
0
 function __construct($id)
 {
     $this->_seat = -1;
     // Initial value, used to determine if there is a runtime cached seat object.
     parent::__construct("tickets", "ticketID", $id);
 }
예제 #14
0
<?php

namespace cd;

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/');
require_once 'SqlObject.php';
if (SqlObject::stringForm(123) != 'i') {
    echo "FAIL 1\n";
}
if (SqlObject::stringForm("abc") != 's') {
    echo "FAIL 2\n";
}
if (SqlObject::stringForm("0123") != 's') {
    echo "FAIL 3\n";
}
if (SqlObject::stringForm(12.34) != 'd') {
    echo "FAIL 4\n";
}
예제 #15
0
 public function __construct($id)
 {
     parent::__construct("kiosk_wares", "ID", $id);
 }
예제 #16
0
 /**
  * Fetches all items where $field_name = $value
  * @param $field_name
  * @param $value
  * @param $tblname
  * @param $classname
  * @param $order_field
  * @param $order 'desc', 'asc' or empty
  */
 public static function getAllByField($field_name, $value, $tblname, $classname, $order_field = '', $order = 'asc')
 {
     if (!is_alphanumeric($tblname)) {
         throw new \Exception('tblname should be alphanumeric, isnt: ' . $tblname);
     }
     if (!is_alphanumeric($field_name)) {
         throw new \Exception('field_name should be alphanumeric, isnt: ' . $field_name);
     }
     if (!is_alphanumeric($order_field)) {
         throw new \Exception('order_field should be alphanumeric, isnt: ' . $order_field);
     }
     if (!Sql::isValidOrder($order)) {
         throw new \Exception('odd order ' . $order);
     }
     $form = self::stringForm($value);
     $q = 'SELECT * FROM ' . $tblname . ' WHERE ' . $field_name . ' = ?' . ($order_field ? ' ORDER BY ' . $order_field . ' ' . strtoupper($order) : '');
     $list = Sql::pSelect($q, $form, $value);
     return SqlObject::ListToObjects($list, $classname);
 }
예제 #17
0
d($x);
$q = 'REPLACE tblSessionData (session_id,session_data,expires) VALUES(?, ?, ?)';
$xxx = Sql::pUpdate($q, 'sss', 666, "hejhej", sql_datetime( time() ) );
d($xxx);
$q = 'INSERT INTO tblLikes (owner,type) VALUES (?, ?)';
$id = Sql::pInsert($q, 'ii', 4,9);
if ($id < 2)    echo "FAIL 5\n";
$w = new Word();
$w->id = 8;
$w->value = "sten";
if (SqlObject::exists($w, 'oWord') != true)   echo "FAIL 10\n";
$w = new Word();
$w->id = 8;
$w->value = "st2en";
if (SqlObject::exists($w, 'oWord') == true)   echo "FAIL 11\n";
*/
// TODO more reliable test of ListToObjects
$q = 'SELECT * FROM tblBookmarks' . ' WHERE owner = ? AND type = ?';
$list = Sql::pSelect($q, 'ii', 2, 100);
$objs = SqlObject::ListToObjects($list, 'Bookmark');
if (count($objs) < 5) {
    echo "FAIL 20\n";
}
$q = 'SELECT * FROM tblBookmarks' . ' WHERE id = ?';
$row = Sql::pSelectRow($q, 'i', 66);
$obj = SqlObject::RowToObject($row, 'Bookmark');
if ($obj->id != 66) {
    echo "FAIL 30\n";
}
$bb = Bookmark::get(66);
d($bb);
예제 #18
0
 function __construct($ID)
 {
     parent::__construct("wannabeComment", "ID", $ID);
 }
예제 #19
0
 /**
  * Create new group instance.
  */
 function __construct($id)
 {
     parent::__construct("groups", "ID", $id);
 }
예제 #20
0
 /** permanently deletes the file from disk */
 public static function unlink($id)
 {
     SqlObject::deleteById($id, self::$tbl_name, 'id');
     $path = self::getUploadPath($id);
     unlink($path);
 }
예제 #21
0
파일: User.php 프로젝트: hultberg/relancms
 function __construct($id)
 {
     $this->_tickets = null;
     parent::__construct("users", "ID", $id);
 }
예제 #22
0
 public static function get($id)
 {
     return SqlObject::getById($id, self::$tbl_name, __CLASS__);
 }
예제 #23
0
 public function store()
 {
     $obj->time_saved = sql_datetime(time());
     return SqlObject::store($this, self::$tbl_name, 'id');
 }
예제 #24
0
 public function store()
 {
     return SqlObject::store($this, self::$tbl_name, 'id');
 }
예제 #25
0
 function __construct($id)
 {
     parent::__construct("seatReg_seatings", "seatID", $id);
 }