git submodule add git@github.com:ninazu/framework.git ./vendor/ninazu/framework
git commit -m "#addSubModule"
git push
cd ./vendor/ninazu/framework
git submodule update --init --recursive
git submodule update --recursive --remote
File -> Settings -> Version Control -> Add -> Directory
VCS -> Git -> Branches -> Repositories -> framework -> LocalBranches -> Checkout
VCS -> UpdateProject
package main
import "fmt"
type LampDiode struct{}
func (l *LampDiode) ScrewOn() string {
return "Lamp 1"
}
type LampIncandescent struct{}
func (l *LampIncandescent) ScrewOn() string {
return "Lamp 2"
}
type Lamp interface {
ScrewOn() string
}
func Chandelier(l Lamp) {
fmt.Println(l.ScrewOn())
}
func main() {
var l1 Lamp
l1 = new(LampDiode)
Chandelier(l1)
var l2 Lamp
l2 = new(LampIncandescent)
Chandelier(l2)
}
VirtualDocumentRoot "/var/www/_custom_/%-2+/%-1"
VirtualDocumentRoot "/var/www/%-2+/%-1"
IN (?,?, ....)
, INSERT IGNORE
<?php
#region DB Connection
$dbName = "test";
$dbHost = "127.0.0.1";
$dbUser = "root";
$dbPassword = "";
$dbCharset = 'UTF8';
$connection = new PDO("mysql:host={$dbHost};dbname={$dbName};charset={$dbCharset}", $dbUser, $dbPassword);
#endregion
#region Pagination
$limit = empty($_GET['limit']) ? 10 : ((int)$_GET['limit']);
$offset = empty($_GET['page']) ? 0 : (($_GET['page'] - 1) * $limit);
#endregion
#region GetTypes
$query = " SELECT
`id`,
`type`
FROM `type`";
$result = $connection
->query($query)
->fetchAll(PDO::FETCH_ASSOC);
$types = array_combine(array_column($result, 'id'), array_column($result, 'type'));
#endregion
#region GetVIIII
$query = " SELECT
`id`,
`added_date`,
`title`,
`type`
FROM `viiii`
ORDER BY `id`
LIMIT {$offset},{$limit}";
$result = $connection
->query($query)
->fetchAll(PDO::FETCH_ASSOC);
#region Render
$output = "<table>";
foreach ($result as $row){
$typeList = explode(',',$row['type']);
$typeList = array_intersect_key($types, array_flip($typeList));
$threatType = implode(", ", $typeList);
$output.=" <tr>
<td>{$row['added_date']}</td>
<td>{$row['title']}</td>
<td>{$threatType}</td>
</tr>";
}
$output.= "</table>";
echo $output;
#endregion
CREATE TABLE IF NOT EXISTS `first` (
`name` varchar(50) CHARACTER SET utf8 NOT NULL,
`key` varchar(50) CHARACTER SET utf8 NOT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `second` (
`key` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`value` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `first` (`name`, `key`) VALUES
('color', 'green'),
('color', 'red'),
('color', 'blue');
INSERT INTO `second` (`key`, `value`) VALUES
('green', 'apple'),
('red', 'cherry'),
('blue', 'sky');
SELECT
CONCAT(f.`name`,':',s.value) AS result,
FROM `first` AS f
INNER JOIN `second` AS s ON s.`key` = f.`key`;
function searchKey($keyName, $sourceArray) {
if (!(is_string($keyName) || is_numeric($keyName)) || !isset($sourceArray[$keyName])) {
return null;
}
$keys = array_keys($sourceArray);
$nextScenario = @$keys[array_search($keyName, $keys) + 1];
return $nextScenario;
}
/**
* @property string $key;
* @property string $foreign_key;
* @property string $repository;
*/
class Helper {
private $data;
public function __construct($data) {
$this->data = $data;
}
public function __set($name, $value) {
$this->data[$name] = $value;
}
public function __get($name) {
return isset($this->data[$name]) ? $this->data[$name] : null;
}
}
$test = new Helper(array(
'key'=>12,
'foreign_key'=>'id',
'repository'=>'',
));
echo $test->key;
$test->key = '23';
echo $test->key;
class C1 {
public $name;
}
class C2 {
public $age;
}
class Helper {
/**
* @var C1|C2
*/
public static $app;
}
Helper::$app->age