Example #1
0
 /**
  * Create a new annotation
  *
  * @param Struct\Annotation $annotation
  * @return void
  */
 public function create(Struct\Annotation $annotation)
 {
     $this->connection->query(sprintf('
         INSERT INTO
            `annotation`
         VALUES (
             null,
             "%s",
             %s,
             %s,
             "%s",
             "%s",
             "%s",
             null
         )', $this->connection->escape_string($annotation->file), (int) $annotation->line, (int) $annotation->character, $this->connection->escape_string($annotation->type), $this->connection->escape_string($annotation->class), $this->connection->escape_string($annotation->message)));
 }
 function escape($value)
 {
     return $this->link->escape_string($value);
 }
Example #3
0
 public function search(array $fields, &$text)
 {
     static $min_word_len = 0;
     /*
      * Short words are ignored, the default minimum length is 4 characters. You can change the min and max word length with the variables ft_min_word_len and ft_max_word_len
      * Words called stopwords are ignored, you can specify your own stopwords, but default words include the, have, some - see default stopwords list.
      * You can disable stopwords by setting the variable ft_stopword_file to an empty string.
      * http://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html
      */
     if (!$min_word_len) {
         mysqli_report(MYSQLI_REPORT_OFF);
         if ($res = parent::query('SHOW VARIABLES LIKE \'ft_min_word_len\'')) {
             $min_word_len = $res->fetch_row();
             $min_word_len = intval($min_word_len[1]);
             $res->free();
         }
         mysqli_report(MYSQLI_REPORT_ERROR);
         $min_word_len = max($min_word_len, 3);
     }
     $text = Poodle_Unicode::as_search_txt($text);
     if (preg_match_all('#[^\\s]{' . $min_word_len . ',}#', $text, $match)) {
         $text = $match[0];
     }
     return ' MATCH (' . implode(',', $fields) . ') AGAINST (\'' . parent::escape_string(implode(' ', $text)) . '\') ';
 }
Example #4
0
 /**
  * Escapes a string for entry into the database
  * 
  * @param string $string
  * @return string
  */
 public function escape($string)
 {
     $this->_getDbh();
     return $this->_dbh->escape_string($string);
 }
Example #5
0
<?php

// codes for searching ---------
$db = new MySQLi('localhost', 'root', 'xxxx', 'xxxx');
if (isset($_GET['keywords'])) {
    $keywords = $db->escape_string($_GET['keywords']);
    $query = $db->query("\r\n\t\tSELECT movie_id, movie_name \r\n\t\tFROM movie\r\n\t\tWHERE movie_name LIKE '%{$keywords}%'\r\n\t\tOR actor LIKE '%{$keywords}%'\r\n\t\tLIMIT 20\r\n\t");
    ?>
    
    <div class="result-count">
    	Found <?php 
    echo $query->num_rows;
    ?>
 results.
    </div>
    
    <?php 
    include 'core/init.php';
    include 'includes/overall/headder.php';
    include 'includes/widgets/spacer.php';
    include 'search.php';
    include 'includes/widgets/spacer.php';
    if ($query->num_rows) {
        while ($r = $query->fetch_object()) {
            //object because using oops style ( mysqli )
            ?>
        	<div id="search_result">
            	<a href="moviehomepage.php?movie_id=<?php 
            echo $r->movie_id;
            ?>
"><?php