This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$s = new SphinxClient; | |
$s->setServer("localhost", 9312); | |
$s->setMatchMode(SPH_MATCH_ANY); | |
$s->setSortMode(SPH_SORT_RELEVANCE); | |
$s->setMaxQueryTime(3); | |
$s->setLimits(0,10); | |
$s->addQuery('test', 'test1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE search_table ( | |
id INT(10) UNSIGNED NOT NULL, | |
weight INTEGER NOT NULL, | |
query VARCHAR(3072) NOT NULL, | |
group_id INTEGER, INDEX(query) | |
) ENGINE=SPHINX CONNECTION="sphinx://localhost:9312/test1"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SELECT * FROM interests JOIN search_table ON (interests.iid = search_table.id) WHERE query='philosophy of science;mode=any'; | |
+-----+-----------------------+------+---------------------+----+--------+--------------------------------+----------+ | |
| iid | title | body | modified | id | weight | query | group_id | | |
+-----+-----------------------+------+---------------------+----+--------+--------------------------------+----------+ | |
| 31 | Philosophy of Science | NULL | 2010-08-01 01:36:26 | 31 | 6 | philosophy of science;mode=any | 0 | | |
| 30 | Philosophy | NULL | 2010-08-01 01:36:22 | 30 | 1 | philosophy of science;mode=any | 0 | | |
| 32 | Philosophy of Math | NULL | 2010-08-01 01:36:30 | 32 | 1 | philosophy of science;mode=any | 0 | | |
+-----+-----------------------+------+---------------------+----+--------+--------------------------------+----------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach($tzlist as $items) { | |
foreach($items as $item) { | |
echo "INSERT INTO timezones (timezone) VALUES ('" . $item . "');"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach($tzlist as $items) { | |
foreach($items as $item) { | |
echo "INSERT INTO timezones (timezone) VALUES ('" . $item . "');"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
static $regions = array( | |
'Africa' => DateTimeZone::AFRICA, | |
'America' => DateTimeZone::AMERICA, | |
'Antarctica' => DateTimeZone::ANTARCTICA, | |
'Aisa' => DateTimeZone::ASIA, | |
'Atlantic' => DateTimeZone::ATLANTIC, | |
'Europe' => DateTimeZone::EUROPE, | |
'Indian' => DateTimeZone::INDIAN, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE timezones ( | |
tid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, | |
timezone VARCHAR(30) NOT NULL | |
) ENGINE=InnoDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE users_timezones ( | |
uid INT(11) NOT NULL, | |
tid INT(11) NOT NULL, | |
FOREIGN KEY (uid) REFERENCES users(uid), | |
FOREIGN KEY (tid) REFERENCES timezones(tid) | |
) ENGINE=InnoDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$len = strlen('America/Argentina/Rio_Gallegos'); | |
echo $len; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT interests.iid, interests.title, COUNT(*) | |
FROM users_interests | |
JOIN interests ON interests.iid = users_interests.iid | |
WHERE users_interests.preference = 'dislike' | |
GROUP BY interests.iid | |
ORDER BY COUNT(*) DESC | |
LIMIT 10; |
OlderNewer