dev-develop
dev-develop http://falk-m.de/Simple Class Libraries
MIT
The Requires
- php >=5.1.0
by Falk MĂŒller
hook php session
1.0.0
1.0.0.0 http://falk-m.de/Simple Class Libraries
MIT
The Requires
- php >=5.1.0
by Falk MĂŒller
hook php session
Wallogit.com
2017 © Pedro PelĂĄez
Simple Class Libraries
composer.json, (*1)
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/falkmueller/myExtensions.git"
}
],
"require": {
"falkm/myExtensions": "dev-develop"
}
}
Create Connection, (*2)
$db = new \myExtensions\mydb("localhost", "test", "root", "");
Insert Statement with Parameter, (*3)
$statement = $db->createQuery("INSERT INTO testtbl (test) values (:name)", array(":name" => "falk"));
$statement->execute();
Select Statement with multible parameter, (*4)
$statement = $db->createQuery("SELECT * FROM testtbl where test in (:name)", array(":name" => array("falk3", "falk2")));
print_r($statement->fetchAll());
first, set global myDb-Instance for Entity-Model, (*5)
\myExtensions\myEntity::$db = $db;
create entitys, (*6)
class user extends \myExtensions\myEntity {
protected static $_table = "user";
public static function fields(){
return array(
"id" => array('type' => 'integer', 'primary' => true, 'autoincrement' => true),
"name" => array('type' => 'string', "default" => ""),
"password" => array('type' => 'string', "default" => ""),
);
}
}
work with entity, (*7)
$user1 = \app\entity\user::selectOne(array("id" => 1));
$new = new \app\entity\user(array("id" => 1, "name" => "mueller"));
if($new->exists()){
echo "exists";
} else {
$new->insert();
}
$new->name = "falk";
$new->update();
echo json_encode($a->toArray());
use myExtensions\myHook;
$hooks = myHook::Instance();
/* add a filter */
$hooks->addFilter("testfilter", function($value){ return "filter-".$value;});
/* call a filter */
echo $hooks->filter("testfilter", 1);//filter-1
echo "<br/>";
/* add middleware (callable, anonymouse function) */
$hooks->addMiddleware("m", function($res, $next){
$res .= " M1-before ";
$res = $next($res);
$res .= " M1-after ";
return $res;
});
class x {
static function y ($res, callable $next,$z1, $z2){
$res .= " M2-bevore ";
$res = $next($res);
$res .= " M2-after ";
return $res;
}
public function call_me($z1, $z2, $res = ''){
$res .= " core ";
return $res;
}
}
* add middleware (callable, static function)*/
$hooks->addMiddleware("m", "x::y");
* call middleware (callable, object function)*/
$x = new x();
$res = $hooks->middleware("m", array($x, "call_me"),"", 1, 2);
echo $res; //M1-before M2-bevore core M2-after M1-after
echo \myExtensions\mySession::Instance()->get("name", "default");
\myExtensions\mySession::Instance()->put("name", "falk");
echo \myExtensions\mySession::Instance()->get("name");
$t = new \myExtensions\myTemplate();
$t->addFunction("testfunction", function($value){ return "TestFunction: {$value}"; });
$t->setSetting("dir", __dir__.'/templates/');
echo $t->render("index.phtml", array("name" => "myExtension"));
templates/index.phtml, (*8)
extend("layout.phtml");?>
<?php $this->startBlock("content", "APPEND") ?>
Dies ist ein Test: <?php echo $this->name ?><br/>
<?php echo $this->testfunction("value"); ?>
<?php $this->endBlock("content") ?>
templates/layout.phtml, (*9)
<html>
<header>
</header>
<body>
HEADER
<div>
<?php $this->startBlock("content") ?>
Dies ist der Content
<?php $this->endBlock("content") ?>
</div>
<?php $this->insert("footer.phtml"); ?>
</body>
</html>
Simple Class Libraries
MIT
hook php session
Simple Class Libraries
MIT
hook php session