Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/07/2019 in all areas

  1. From the docs: This means that the expression you want to be matched is a single, text (string) value. If you're using a prepared statement, in PHP, with PDO, that means a single question mark (?) or a single ":name" placeholder if you're going for named parameters. A quick demo example: <?php $db = new PDO("sqlite::memory:"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->exec("CREATE VIRTUAL TABLE example USING FTS5 (a, b)"); $db->exec("INSERT INTO example (a, b) VALUES ('this is an amazing message', 'kittens are lovely')"); $db->exec("INSERT INTO example (a, b) VALUES ('this is a great message', 'dogs are also lovely')"); $db->exec("INSERT INTO example (a, b) VALUES ('this is a message', 'hamsters are best')"); $query = $db->prepare('SELECT * FROM example WHERE example MATCH ?'); $query->execute(array('(b: kittens) OR (a: great)')); $rows = $query->fetchAll(); print_r($rows); The above example outputs the two matching rows. Array ( [0] => Array ( [a] => this is an amazing message [b] => kittens are lovely ) [1] => Array ( [a] => this is a great message [b] => dogs are also lovely ) ) Hope that helps.
    1 point
  2. A (very) brief note about Countable objects Classes implementing the Countable interface define and implement their own count() method. The DOMNodeList class is one such class. Instances of classes that implement the Countable interface can be passed to the count() function, and their own special count() method gets called. In DOMNodeList's case, that method returns the number of nodes in the list. There is nothing stopping you from calling the count() method on the object (e.g. $myobject->count()) rather than the count() function (e.g. count($myobject)), if that's what you want to do. How the heck am i supposed to count the childNodes? Back to your original question. There are several ways to get the number of nodes in a DOMNodeList (which is what your $dom->childNodes is). 1. $dom->childNodes->length 2. count($dom->childNodes) 3. $dom->childNodes->count()
    1 point
  3. Post code we can read instead of redacted text and someone might look at it.
    0 points
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.