示例#1
1
function getEquip()
{
    $db = new Database();
    $link = $db->connect();
    $result = $db->select($link, 'equip_type');
    return $result;
}
示例#2
0
 /**
  * Populates the search index with content from all pages
  */
 protected function populateSearchIndex()
 {
     $res = $this->db->select('page', 'MAX(page_id) AS count');
     $s = $this->db->fetchObject($res);
     $count = $s->count;
     $this->output("Rebuilding index fields for {$count} pages...\n");
     $n = 0;
     $fields = array_merge(Revision::selectPageFields(), Revision::selectFields(), Revision::selectTextFields());
     while ($n < $count) {
         if ($n) {
             $this->output($n . "\n");
         }
         $end = $n + self::RTI_CHUNK_SIZE - 1;
         $res = $this->db->select(['page', 'revision', 'text'], $fields, ["page_id BETWEEN {$n} AND {$end}", 'page_latest = rev_id', 'rev_text_id = old_id'], __METHOD__);
         foreach ($res as $s) {
             try {
                 $title = Title::makeTitle($s->page_namespace, $s->page_title);
                 $rev = new Revision($s);
                 $content = $rev->getContent();
                 $u = new SearchUpdate($s->page_id, $title, $content);
                 $u->doUpdate();
             } catch (MWContentSerializationException $ex) {
                 $this->output("Failed to deserialize content of revision {$s->rev_id} of page " . "`" . $title->getPrefixedDBkey() . "`!\n");
             }
         }
         $n += self::RTI_CHUNK_SIZE;
     }
 }
 public function version_move($table, $model, $id, $sid, $type)
 {
     if (!is_numeric($id)) {
         throw new Exception("Must pass subject id", 1);
     }
     if (!is_numeric($sid)) {
         throw new Exception("Must pass target id", 1);
     }
     if ($id == $sid) {
         throw new Exception("Subject and target cannot be the same", 1);
     }
     $types = array('move_to_last_child', 'move_to_first_child', 'move_to_next_sibling', 'move_to_prev_sibling');
     if (!in_array($type, $types)) {
         throw new Exception("Must pass move type", 1);
     }
     $db = new Database();
     $page_id = $db->select('page_id')->from($table)->where('id', $id)->get()->current()->page_id;
     $page_sid = $db->select('page_id')->from($table)->where('id', $sid)->get()->current()->page_id;
     self::version_position_table($table);
     $id = $db->select('id')->from($table)->where('page_id', $page_id)->get()->current()->id;
     $sid = $db->select('id')->from($table)->where('page_id', $page_sid)->get()->current()->id;
     $id_node = ORM::factory($model, $id);
     $item = ORM::factory($model, $sid);
     $item->{$type}($id_node);
 }
示例#4
0
 public function testDeleteAll()
 {
     $users = $this->database->select(User::class);
     $this->database->delete($users);
     $users = $this->database->select(User::class);
     $this->assertEquals(0, count($users));
 }
 /**
  * undocumented function
  *
  * @param string $target 
  * @param string $copy_left_from 
  * @param string $left_offset 
  * @param string $level_offset 
  * @return void
  * @author Andy Bennett
  */
 protected function insert($target, $copy_left_from, $left_offset, $level_offset)
 {
     $db = new Database();
     $obj_id = $db->select($this->parent_model . '_' . $this->primary_key)->from($this->table_name)->where('id', $target)->get()->current()->{$this->parent_model . '_' . $this->primary_key};
     versions_helper::version_position_table($this->table_name, $this->version);
     $target_id = $db->select($this->primary_key)->from($this->table_name)->where($this->parent_model . '_' . $this->primary_key, $obj_id)->get()->current()->{$this->primary_key};
     return parent::insert($target_id, $copy_left_from, $left_offset, $level_offset);
 }
示例#6
0
 public static function getMainElements($type)
 {
     $db = new Database();
     if ($type === "boards") {
         return $db->select('SELECT id, ownerid, catid, name, picture, updated' . ' FROM boards ORDER BY id DESC LIMIT 3');
     } else {
         if ($type === "products") {
             return $db->select('SELECT id, ownerid, catid, name, picture, price, source' . ' FROM products ORDER BY id DESC LIMIT 3');
         }
     }
 }
示例#7
0
 /**
  * 取得数据,支持批量取
  * @param string/array $key
  * @return mixed
  */
 public function get($key)
 {
     $key_map = array();
     if (is_array($key)) {
         $md5_key = array();
         foreach ($key as &$k) {
             $key_map[$this->prefix . $k] = $k;
             $k = $this->prefix . $k;
             $md5_key[] = md5($k);
         }
         $this->_handler->in('key', $md5_key);
     } else {
         $key_map[$this->prefix . $key] = $key;
         $key = $this->prefix . $key;
         $this->_handler->where('key', md5($key))->limit(1);
     }
     $rs = $this->_handler->select('key_string', 'value', 'number')->from($this->tablename)->and_where_open()->where('expire', 0)->or_where('expire', TIME, '>')->and_where_close()->get();
     if ($rs->count()) {
         if (is_array($key)) {
             $return = array();
             foreach ($rs as $data) {
                 $data_key = $key_map[$data['key_string']];
                 $return[$data_key] = $data['value'];
                 if ('' === $data['value']) {
                     $return[$data_key] = $data['number'];
                 } else {
                     $this->_de_format_data($return[$data_key]);
                 }
             }
         } else {
             $return = $rs->current();
             if ('' === $return['value']) {
                 $return = $return['number'];
             } else {
                 $return = $return['value'];
                 $this->_de_format_data($return);
             }
         }
         if (IS_DEBUG) {
             Core::debug()->info($key, 'database cache hit key');
         }
         unset($rs);
         return $return;
     } else {
         if (IS_DEBUG) {
             Core::debug()->error($key, 'database cache mis key');
         }
     }
     return false;
 }
示例#8
0
 /**
  * 取得数据,支持批量取
  * @param string/array $key
  * @return mixed
  */
 public function get($key)
 {
     if (IS_DEBUG) {
         $key_bak = $key;
     }
     if (is_array($key)) {
         $this->_handler->in('key', array_map('md5', $key));
     } else {
         $this->_handler->where('key', md5($key))->limit(1);
     }
     $rs = $this->_handler->select('key', 'value', 'number')->from($this->tablename)->and_where_open()->where('expire', 0)->or_where('expire', TIME, '>')->and_where_close()->get();
     if ($rs->count()) {
         if (is_array($key)) {
             $return = array();
             foreach ($rs as $data) {
                 $return[$data['key']] = $data['value'];
                 if ('' === $data['value']) {
                     $return[$data['key']] = $data['number'];
                 } else {
                     if ($this->_compress) {
                         //启用数据压缩
                         $return[$data['key']] = gzuncompress($data['value']);
                     }
                     $return[$data['key']] = @unserialize($return);
                 }
             }
         } else {
             $return = $rs->current();
             if ('' === $return['value']) {
                 $return = $return['number'];
             } else {
                 $return = $return['value'];
                 if ($this->_compress) {
                     //启用数据压缩
                     $return = gzuncompress($return);
                 }
                 $return = @unserialize($return);
             }
         }
         if (IS_DEBUG) {
             Core::debug()->info($key_bak, 'database cache hit key');
         }
         return $return;
     } else {
         if (IS_DEBUG) {
             Core::debug()->error($key_bak, 'database cache mis key');
         }
     }
     return false;
 }
示例#9
0
 /**
  * This method will get the IDS of the GSMs we want to filter by
  * 
  * This should cause no problems with doubling up on relaitonships as it creates its own db object, 
  * then just does a check against paper_id with out requiring a new relationship
  * 
  * @param array $values an array of selected gsms 'ranges' that come in the form of '100-150' 
  */
 public function gsms($values)
 {
     // create a new db object so we dont screw with the relationship on the search.
     $db = new Database();
     $db->select('paper_id')->from('collections')->join('pigments', 'collections.id', 'pigments.collection_id')->join('sheets', 'pigments.id', 'sheets.pigment_id')->join('gsms', 'sheets.id', 'gsms.sheet_id')->groupby('paper_id');
     // loop through each of the values (100-150), break them apart into a min/max and then do a between
     foreach ($values as $value) {
         $value = explode('-', $value);
         if (isset($value[0]) && isset($value[1]) && $value[0] < $value[1]) {
             $db->orwhere('gsms.name BETWEEN', "'" . $value[0] . "' AND '" . $value[1] . "'", false);
         }
     }
     $result = $db->get();
     $results = $result->result_array(false);
     // loop through each of the resultsm put the paper_ids into a cleaned array then add it to the searches params
     $papers = array();
     foreach ($results as $result) {
         $papers[] = $result['paper_id'];
     }
     if (count($papers)) {
         $this->db->in('papers.id', $papers);
         // note how this is $this->db :: ie hits the searches object to filter the papers by
     } else {
         $this->db->where('papers.id', '0');
         /// if there are no paper with that gsm, force the main query to return no results.
     }
 }
示例#10
0
 public static function isAuthenticated()
 {
     //TODO
     //look if Token is present in $_Session
     Session::get('UserID') ? $auth = 'TRUE' : ($auth = 'FALSE');
     if ($auth === 'TRUE') {
         return TRUE;
     } else {
         if (isset($_COOKIE["RemembeR"])) {
             $db = new Database();
             //Get TOKEN from $_COOKIE
             //hash(Token) and compare with hashed Tokens in the Database
             $userdata['tokenhash'] = hash('sha1', $_COOKIE["RemembeR"]);
             echo $userdata['tokenhash'];
             $arr = $db->select("SELECT id, tokenhash FROM users WHERE tokenhash = :tokenhash LIMIT 1", $userdata);
             var_dump($arr);
             if (sizeof($arr[0]['id']) !== 0) {
                 //Set 'UserID' in Session
                 Session::set('UserID', $arr[0]['id']);
                 //Renew Cookie
                 $token = hash("md5", $arr[0]['id'] . Session::get('ID'));
                 $userdata['id'] = $arr[0]['id'];
                 $userdata['tokenhash'] = hash("sha1", $token);
                 $db->update("users", $userdata, "id = :id");
                 setcookie("RemembeR", $token, time() + 259200, "/", "studi.f4.htw-berlin.de", false, true);
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
示例#11
0
 function copyExactMatch($srcTable, $dstTable, $copyPos)
 {
     $numRowsCopied = 0;
     $srcRes = $this->dbw->select($srcTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     $dstRes = $this->dbw->select($dstTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     if ($srcRes->numRows()) {
         $srcRow = $srcRes->fetchObject();
         $srcFields = array_keys((array) $srcRow);
         $srcRes->seek(0);
         $dstRowsSeen = [];
         # Make a hashtable of rows that already exist in the destination
         foreach ($dstRes as $dstRow) {
             $reducedDstRow = [];
             foreach ($srcFields as $field) {
                 $reducedDstRow[$field] = $dstRow->{$field};
             }
             $hash = md5(serialize($reducedDstRow));
             $dstRowsSeen[$hash] = true;
         }
         # Copy all the source rows that aren't already in the destination
         foreach ($srcRes as $srcRow) {
             $hash = md5(serialize((array) $srcRow));
             if (!isset($dstRowsSeen[$hash])) {
                 $this->dbw->insert($dstTable, (array) $srcRow, __METHOD__);
                 $numRowsCopied++;
             }
         }
     }
     return $numRowsCopied;
 }
示例#12
0
 public static function display()
 {
     $messages = "";
     if ($_POST['cc_form'] === 'add-group') {
         $group = $_POST['group'];
         $rows = Database::select('users', 'name', array('name = ? AND type = ?', $group, 'group'), null, 1)->fetch(PDO::FETCH_ASSOC);
         if (!empty($rows)) {
             $messages .= Message::error(__('admin', 'group-in-use'));
         } else {
             $row = DB::select('users', array('data'), array('users_id = ?', $_GET['parent']))->fetch(PDO::FETCH_ASSOC);
             $inheritance = unserialize($row['data']);
             $inheritance = $inheritance['permissions'];
             $result = Database::insert('users', array('name' => filter('admin_add_group_name', $group), 'type' => 'group', 'group' => '-1', 'data' => serialize(filter('admin_add_group_data', array('permissions' => $inheritance)))));
             if ($result === 1) {
                 $messages .= Message::success(__('admin', 'group-added'));
             }
         }
     }
     $form = new Form('self', 'post', 'add-group');
     $form->startFieldset(__("admin", 'group-information'));
     $form->addInput(__('admin', 'group-name'), 'text', 'group', self::get('group'));
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->addSelectList(__('admin', 'inherit-permissions'), 'parent', $groups);
     plugin('admin_add_group_custom_fields', array(&$form));
     $form->addSubmit('', 'add-group', __('admin', 'add-group'));
     $form->endFieldset();
     plugin('admin_add_group_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(__('admin', 'add-group'), $messages . $form);
 }
示例#13
0
 function getUserBySession($userID)
 {
     $db = new Database();
     $query = "SELECT * FROM users  WHERE user_id='{$userID}' ";
     $arrayUser = $db->select($query);
     return $arrayUser;
 }
示例#14
0
文件: yagdemo.php 项目: ThorstenS/YAG
 public function index($page = 1)
 {
     $db = new Database();
     // You can assign anything variable to a view by using standard OOP
     // methods. In my welcome view, the $title variable will be assigned
     // the value I give it here.
     $this->template->title = 'Welcome to YAG demo!';
     $grid = Grid::factory()->set('display_head', true)->set('display_foot', true)->set('display_body', true)->set('table_attributes', array('id' => 'demo_table_1', 'width' => '100%'));
     $grid->CheckboxField('id')->set('title', 'ID')->set('checked', array(2, 3, 4, 6, 9))->set('sortable', true)->set('foot', form::checkbox('checkall', 'yes', false, "onclick=\"check_all('id[]');\"") . form::dropdown('action', array('edit' => 'Edit', 'delete' => 'Delete'), 'edit') . form::submit('submit', 'OK'))->set('extra', array("onclick" => "checkbox_check('id[]')"));
     $grid->TextField('id')->set('title', 'ID')->set('sortable', true);
     $grid->TextField('text')->set('title', 'Text')->set('sortable', true);
     $grid->DateField('date')->set('title', 'Date')->set('format', 'Y-m-d')->set('sortable', true);
     $grid->ActionField()->set('title', 'Action')->add_action('edit', 'id', 'Edit', 'http://www.path.to/my/controller')->add_action('delete', 'id', 'Delete');
     $offset = (int) ($page - 1) * 10;
     $offset = $offset < 0 ? 0 : $offset;
     $order_field = 'id';
     $order_direction = 'asc';
     if ($this->input->get('order_by') and $grid->field_exists($order_field, true)) {
         $order_field = $this->input->get('order_by');
     }
     if ($this->input->get('order_direction') and in_array(strtoupper($this->input->get('order_direction')), array('ASC', 'DESC'))) {
         $order_direction = strtoupper($this->input->get('order_direction'));
     }
     $data = $db->select($grid->get_fields(true))->from('demotable')->limit(10)->offset($offset)->orderby($order_field, $order_direction)->get();
     $count = $db->query('SELECT FOUND_ROWS() AS rows;')->current();
     $this->pagination = new Pagination(array('total_items' => $count->rows, 'items_per_page' => 10));
     $grid->set('extra_row_foot', '<td colspan="' . count($grid->fields) . '">' . $this->pagination->render() . '</td>');
     $grid->set('data', $data);
     $html = $grid->render();
     // Get Javascript for checkbox gimmicks
     $this->template->checkall_js = $grid->render_js('checkall');
     $this->template->content = $html;
 }
示例#15
0
 /**
  * Retrieve a value from the variables.
  * @param string $name Variable name
  * @param variant $default Return value if no variable exists with this name.
  * @param boolean $caching Use the Kohana cache to retrieve the value?
  */
 public static function get($name, $default = false, $caching = true)
 {
     $value = null;
     if ($caching) {
         $cache = Cache::instance();
         // get returns null if no value
         $value = $cache->get("variable-{$name}");
     }
     if ($value === null) {
         $db = new Database();
         $r = $db->select('value')->from('variables')->where('name', $name)->get()->result_array(false);
         if (count($r)) {
             $array = json_decode($r[0]['value']);
             $value = $array[0];
             if ($caching) {
                 $cache->set("variable-{$name}", $value, array('variables'));
             }
         }
     }
     if ($value !== null) {
         return $value;
     } else {
         return $default;
     }
 }
示例#16
0
function buscar($b)
{
    include 'crud/class/mysql_crud.php';
    $db = new Database();
    $db->connect();
    $db->select('proveedor', 'idproveedor, razonsocial, numerodoc', NULL, ' UPPER(numerodoc) LIKE "%' . strtoupper($b) . '%"', NULL, '1');
    // Table name, Column Names, WHERE conditions, ORDER BY conditions
    $res = $db->getResult();
    $contar = $db->numRows();
    if ($contar == 0) {
        echo "No se han encontrado resultados para '<b>" . $b . "</b>'.";
    } else {
        foreach ($res as $key => $value) {
            //$name = $value['numerodoc'].'|'.$value['razonsocial'].'|'.$value['idproveedor'];
            //array_push($data, $name);
            $id = $value['idproveedor'];
            $razonsocial = $value['razonsocial'];
            $numerodoc = $value['numerodoc'];
            $data = array('idproveedor' => $id, 'razonsocial' => $razonsocial, 'numerodoc' => $numerodoc);
            //echo $data['razonsocial'];
        }
        echo json_encode($data);
        exit;
    }
}
/**
 * Get all categories and users ids from gradebook
 * @return array Categories and users ids
 */
function getAllCategoriesAndUsers()
{
    $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
    $jointable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
    $joinStatement = ' JOIN ' . $jointable . ' ON ' . $table . '.evaluation_id = ' . $jointable . '.id';
    return Database::select('DISTINCT ' . $jointable . '.category_id,' . $table . '.user_id', $table . $joinStatement);
}
    /**
     * Check whether the username and password are valid
     * @param string $username The username
     * @param string $password the password
     * @return boolean Whether the password belongs to the username return true. Otherwise return false
     */
    public static function isValidUser($username, $password)
    {
        if (empty($username) || empty($password)) {
            return false;
        }

        $userTable = Database::get_main_table(TABLE_MAIN_USER);

        $whereConditions = array(
            "username = '******' " => $username,
            "AND password = '******'" => sha1($password)
        );

        $conditions = array(
            'where' => $whereConditions
        );

        $table = Database::select('count(1) as qty', $userTable, $conditions);

        if ($table != false) {
            $row = current($table);

            if ($row['qty'] > 0) {
                return true;
            }
        }

        return false;
    }
示例#19
0
    public function modify($id, $concepto, $moneda, $monto, $tipo_op)
    {
        include_once '../db.php';
        $db = new Database();
        $db->connect();
        $rows = array();
        $rows[concepto] = '"' . $concepto . '"';
        $rows[moneda] = $moneda;
        $rows[monto] = $monto;
        $rows[pesos] = $monto;
        $rows[tipo_op] = $tipo_op;
        $rows[editor] = '"pepe"';
        if ($moneda == 1) {
            $dolar = new dolar();
            $dolarCompra = $dolar->getDolar();
            $rows[pesos] = round($monto * $dolarCompra, 2);
        }
        $db->update('pagos', $rows, 'id=' . $id);
        $date = $db->select('pagos', 'DATE_FORMAT(fecha,"%d-%m-%Y") as fecha', 'id=' . $id, '', '');
        foreach ($date as $d) {
            $fechaMod = $d[fecha];
        }
        $monedaOutput = array('£', 'U$D');
        $htm = '<span class="col1">' . $fechaMod . '</span>
				<span class="col2">' . $concepto . '</span>
				<span class="col3 tipo_op' . $tipo_op . '">' . $monedaOutput[$moneda] . ' ' . $monto . '</span>
				<span class="col4">
					<a class="modifyOpTable" href="javascript:;" onClick="showModGastos(' . $id . ',\'' . str_replace("'", "\\'", $concepto) . '\',\'' . $monto . '\',' . $moneda . ',' . $tipo_op . ')">&nbsp;</a>
                   	<a class="deleteOpTable" href="javascript:;" onClick="gastos(\'del\',' . $id . ',\'' . str_replace("'", "\\'", $concepto) . '\')">&nbsp;</a>
					</span>';
        return $htm;
    }
示例#20
0
	/**
	 * Very simple select
	 *
	 * @param    string   What to order by
	 * @param    string   Where statement
	 * @param    string   Columns to select
	 * @return   result   Result of query
	 */
	function select($where = '', $orderby='',  $cols = '*', $limit = '') {
	
		if (!empty($this->id) && empty($where)) $where .= $this->primaryKey." = $this->id";
		
		return parent::select($this->table, $orderby, $where, $cols, $limit);
	
	}
示例#21
0
 public static function loadData($table, $data, $where = null, $order = null)
 {
     $db = new Database();
     $link = $db->connect();
     $result = $db->select($link, $table, $data, $where, $order);
     return $result;
 }
示例#22
0
    public function modify($id, $concepto, $moneda, $monto, $tipo_op)
    {
        include_once '../db.php';
        $db = new Database();
        $db->connect();
        $rows = array();
        $rows[concepto] = '"' . $concepto . '"';
        $rows[moneda] = $moneda;
        $rows[monto] = $monto;
        $rows[pesos] = $monto;
        $rows[tipo_op] = $tipo_op;
        $rows[editor] = '"' . $_SESSION[userPagos] . '"';
        if ($moneda == 1) {
            $dolar = new dolar();
            $dolarCompra = $dolar->getDolar();
            $rows[pesos] = round($monto * $dolarCompra, 2);
        }
        $db->update('pagos', $rows, 'id=' . $id);
        $date = $db->select('pagos', 'DATE_FORMAT(fecha,"%d-%m-%Y") as fecha', 'id=' . $id, '', '');
        foreach ($date as $d) {
            $fechaMod = $d[fecha];
        }
        $monedaOutput = array('£', 'U$D');
        $htm = '<p class="tableConcepto">
				' . $concepto . '
				<span class="tableFecha">' . $fechaMod . '</span>
			</p>
			<span class="tableMonto tipo_op' . $tipo_op . '"><span class="fontMoneda' . $moneda . '">' . $monedaOutput[$moneda] . '</span> ' . $monto . '</span>
			<span class="tableOpciones">
				<a class="modifyOpTable" href="javascript:;" onClick="toggleEditor(5,' . $id . ',\'' . str_replace("'", "\\'", $concepto) . '\',\'' . $monto . '\',' . $moneda . ',' . $tipo_op . ')">&nbsp;</a>
	<a class="deleteOpTable" href="javascript:;" onClick="delPayment(\'payment\',' . $id . ',\'' . str_replace("'", "\\'", $concepto) . '\',0)">&nbsp;</a>
			</span>';
        return $htm;
    }
示例#23
0
 public function changePassword($pwd)
 {
     if (empty($pwd->current)) {
         return 'Current password is required.';
     }
     if (empty($pwd->new)) {
         return 'New password cannot be blank.';
     }
     if (empty($pwd->confirm) || $pwd->new != $pwd->confirm) {
         return "Passwords don't match";
     }
     if (strlen($pwd->new) < 5) {
         return 'Password is too short';
     }
     $db = new Database();
     $db->select('Users', 'Email', null, "StudentId is null and Email ='" . $pwd->email . "' and Password=password('" . $pwd->current . "');");
     $res = $db->getResult();
     if (!array_key_exists('Email', $res)) {
         return 'Wrong password';
     }
     if (!$db->sql("UPDATE Users SET Password=password('" . $pwd->new . "') WHERE StudentId is null and Email ='" . $pwd->email . "' and Password=password('" . $pwd->current . "');")) {
         $res = $db->getResult();
         return $res;
     }
     return true;
 }
示例#24
0
 function getBooksByIdUser($idUser, $idBook)
 {
     $db = new Database();
     $query = "SELECT * FROM books b LEFT JOIN users u  ON b.fk_owner = u.user_id WHERE b.id_book ='{$idBook}' AND b.fk_user='******'";
     $arrayBooks = $db->select($query);
     return $this->arrayBooks = $arrayBooks;
 }
 function testSelect()
 {
     $db = new Database();
     $sql = "SELECT COUNT(*) AS count FROM members";
     $result = $db->select($sql);
     $this->assertTrue($result[0]["count"] === 0);
 }
示例#26
0
  public function searchVideos($pSrchString)
  {
    if (strlen($pSrchString) > 0)
    {
      $lSrchString = trim($pSrchString);
      $lSplitter = preg_split('/\s+/', $lSrchString);
	  
      if (count($lSplitter) > 0)
      {
        $lStatement = "SELECT ID, VideoTitle, Duration FROM VideoDB WHERE 1=1 ";
		
         foreach ($lSplitter as $lKey => $lValue)
           $lStatement .= " AND VideoTitle like '%$lValue%'";
	  
         $lStatement .= " LIMIT 0," . Config::$YoutubeMaxLocalResults;
	  
        $lDB = new Database();
        $lDB->connect();  
	  
        $lDB->select($lStatement);  
        $lResult = $lDB->getResult();
        $lDB->disconnect(); 
      }
    }
	
    return($lResult);	
  }
示例#27
0
 /**
  * Check if the video chat exists by its room name
  * @param string $name The video chat name
  *
  * @return boolean
  */
 public static function nameExists($name)
 {
     $resultData = Database::select('COUNT(1) AS count', Database::get_main_table(TABLE_MAIN_CHAT_VIDEO), ['where' => ['room_name = ?' => $name]], 'first');
     if ($resultData !== false) {
         return $resultData['count'] > 0;
     }
     return false;
 }
 /**
  * Gets the number of options available for this field
  * @param int $field_id
  * @return int Number of options
  * @assert ('') === false
  * @assert (-1) == 0
  * @assert (0) == 0
  */
 public function get_count_by_field_id($field_id)
 {
     if (empty($field_id)) {
         return false;
     }
     $row = Database::select('count(*) as count', $this->table, array('where' => array('field_id = ?' => $field_id)), 'first');
     return $row['count'];
 }
示例#29
0
 public static function get()
 {
     if (isset($_POST['id'])) {
         $whereValues = [self::ID => $_POST['id']];
     }
     $result = Database::select(self::TABLE_NAME, $whereValues);
     echo json_encode($result);
 }
示例#30
0
function myplugin_activate()
{
    $db = new Database();
    $db->connect();
    // Create Items Table
    $filesTableExists = $db->select("items");
    if (!$filesTableExists) {
        $sql = "CREATE TABLE items (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tname VARCHAR(200) NOT NULL,\n\t\t\t\t\tuploaded_timestamp timestamp,\n\t\t\t\t\tlast_updated_timestamp timestamp\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Items Table created.<br>";
        } else {
            echo "Error When Creating Items Table<br>";
        }
    } else {
        echo "Items Table already exists.<br>";
    }
    // Create Files Table
    $filesTableExists = $db->select("files");
    if (!$filesTableExists) {
        //change on uploaded attr
        $sql = "CREATE TABLE files (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tfileName VARCHAR(300) NOT NULL,\n\t\t\t\t\tname VARCHAR(200) NOT NULL,\n\t\t\t\t\tpath VARCHAR(200) NOT NULL,\n\t\t\t\t\tviews INT NOT NULL,\n\t\t\t\t\tuploadedTimestamp timestamp,\n\t\t\t\t\tlastUpdatedTimestamp timestamp\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Files Table created.<br>";
        } else {
            echo "Error When Creating Files Table<br>";
        }
    } else {
        echo "Files Table already exists.<br>";
    }
    // Create File Connector Table
    $fileConnectorTableExists = $db->select("file_connector");
    if (!$fileConnectorTableExists) {
        $sql = "CREATE TABLE file_connector (\n\t\t\t\t\tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t\tfile_id INT NOT NULL,\n\t\t\t\t\titem_id INT NOT NULL,\n\t\t\t\t\tlabel VARCHAR(50) NOT NULL,\n\t\t\t\t\tfeatured_image INT NOT NULL,\n\t\t\t\t\tdisplay INT NOT NULL\n\n\t\t\t\t)";
        $result = $db->sql($sql);
        if ($result) {
            echo "Category Connector Table created.<br>";
        } else {
            echo "Error When Creating Category Connector Table<br>";
        }
    } else {
        echo "Category Connector Table already exists.<br>";
    }
}