allo from で指定したipアドレスからのアクセスを許可する
.htaccess
order deny,allow deny from all allow from xxx.xxx.xxx.xxx
なるほど!

随机应变 ABCD: Always Be Coding and … : хороший
allo from で指定したipアドレスからのアクセスを許可する
.htaccess
order deny,allow deny from all allow from xxx.xxx.xxx.xxx
なるほど!

銘柄リストから、それぞれのテーブルを作っていきます。sqlにはif not existsを入れます。
$time_start = microtime(true);
$dsn = "mysql:dbname=equity;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$sql = "select code from lists";
$stmt = $dbh->query($sql);
while($result = $stmt->fetch(PDO::FETCH_ASSOC)){
$code[] = $result["code"];
}
foreach($code as $value){
$sql = "create table if not exists equity.code".$value."(
id int unsigned auto_increment primary key,
date int,
close int
)ENGINE = MYISAM;";
$stmt = $dbh->query($sql);
}
$time = microtime(true) - $time_start;
echo "{$time}秒";
mysql側 入ってます。

経過時間:35秒

問題は次ですが、
アップデートがなかった場合:11.73秒

localで走らせるので、そこまで大きな問題ではなさそうですね。
一からもう一度やってみましたが、大体同じ時間です。
試しにgoogle financeから1個データを入れてみます。
これは。。。かなりやる気なくなってきた。

$time_start = microtime(true);
$dsn = "mysql:dbname=equity;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$code= '2338';
$sql = "create table equity.code".$code."(
id int unsigned auto_increment primary key,
date int,
close int
)ENGINE = MYISAM;";
$stmt = $dbh->query($sql);
$time = microtime(true) - $time_start;
echo "{$time}秒";

以下で取得可能です。
SELECT DISTINCT colname FROM tablename;
mysql> select distinct sector from lists;
+————————–+
| sector |
+————————–+
| 水産・農林業 |
| 卸売業 |
| 建設業 |
| 非鉄金属 |
| 鉱業 |
| 機械 |
| サービス業 |
| 金属製品 |
| 情報・通信 |
| 食料品 |
| 医薬品 |
| 不動産業 |
| 陸運業 |
| その他金融業 |
| 小売業 |
| その他製品 |
| 繊維製品 |
| 電気機器 |
| ガラス・土石製品 |
| 証券業 |
| 輸送用機器 |
| REIT銘柄一覧 |
| 石油・石炭製品 |
| 化学 |
| パルプ・紙 |
| 精密機器 |
| ゴム製品 |
| 鉄鋼 |
| 銀行業 |
| 保険業 |
| 倉庫・運輸関連業 |
| 海運業 |
| 空運業 |
| 電気・ガス業 |
+————————–+
34 rows in set (0.05 sec)
早く気づけばよかった。
select * from table where で条件を記載します。
$code = empty($_GET["code"])? 'null' : $_GET["code"];
$dsn = "mysql:dbname=equity;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$sql = "select * from lists where code = $code";
$stmt = $dbh->query($sql);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$sector = $result['sector'];
$market = $result['market'];
echo "<b>".$result['name']. "</b>(".$code.") ";
echo $result['sector'] ." ".$result['market']. "<br><br>";
echo "同業種の銘柄(".$sector.")"."<br>";
$sql2 = "select * from lists where market = '$market' AND sector = '$sector' and code != $code";
$stmt2 = $dbh->query($sql2);
while($result = $stmt2->fetch(PDO::FETCH_ASSOC)){
echo $result["code"]." ".$result["name"]. "<br>";
}


echo $_GET["code"];

コードの情報をDBから取得する
$time_start = microtime(true);
$code = empty($_GET["code"])? 'null' : $_GET["code"];
echo $code. "<br>";
$dsn = "mysql:dbname=equity;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$sql = "select * from lists where code = $code";
$stmt = $dbh->query($sql);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
echo $result['name']. "<br>";
echo $result['sector']. "<br>";
echo $result['market']. "<br>";
echo "<br>";
$time = microtime(true) - $time_start;
echo "{$time}秒";
OK!

パラメータからデータを読み込む

パラメータを変える

なるほど
www/cake/に testというappを作っています。
それぞれのhtaccessのRewriteBaseでカレントディレクトリを指定してあげます。
/cake/.htaccess
RewriteEngine on RewriteRule ^$ test/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] RewriteBase /
/cake/test/.htaccess
RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] RewriteBase /test
/cake/test/webroot/.htaccess
RewriteEngine On RewriteBase /test/webroot RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
きたー

ここまでもってくるの、結構煩雑だな~
VPSの方が簡単にセットアップできるという謎現象ですね。
intlも入ったし、さあ、確認とおもったら、
php composer.phar create-project --prefer-dist cakephp/app myapp
Problem 1
– cakephp/cakephp 3.5.9 requires ext-intl * -> the requested PHP extension intl is missing from your system.

これはがっかりしますね。
確かに、php -i | grep intlで何も表示されない。
原因は、この php.ini は/usr/local/php/5.6/lib/php.iniの方を読み込んでいるから。
コントロールパネルで設定したphp.iniの方は、
php -c /home/[username]/www/php.ini -i | grep intl
で表示される。
というわけで、cake3.5を入れる際も、以下のように打ちます。
php -c /home/[username]/www/php.ini composer.phar create-project --prefer-dist cakephp/app test
こんどは上手くいってるようです。

intlがないと動きません。
というこで、まずicuライブラリを入れます。ここはサクサクいきます。
$ cd ~/local/src $ wget http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.tgz $ tar zxvf icu4c-54_1-src.tgz $ cd icu/source $ ./configure --prefix=$HOME/local $ gmake $ gmake install
続いて、intl
$ cd ~/local/src $ wget http://pecl.php.net/get/intl-3.0.0.tgz $ tar zxvf intl-3.0.0.tgz $ cd intl-3.0.0 $ phpize
次に、.configureをしますが、phpのバージョンを指定します。
/php/5.6/
ここでphpのバージョンを指定しないと、エラーになりました。
$ ./configure --prefix=$HOME/local --with-icu-dir=$HOME/local --with-php-config=/usr/local/php/5.6/bin/php-config $ make
あとは、php.initでextensionのパスを通します。
phpinfo()に入ってることを確認。

バージョン指定のところ、毎回見落とすんだよな~
自暴自棄です。
何も問題なくはいりました。
php composer.phar create-project –prefer-dist cakephp/app test

OK♪