nicksagona on 5.3.1
nicksagona on master
Add support for column select o… (compare)
nicksagona on v5-dev
Add support for column select o… (compare)
nicksagona on 3.6.0
nicksagona on v3-dev
Update workflow (compare)
nicksagona on master
Update workflow (compare)
nicksagona on master
Update version and copyright (compare)
nicksagona on v3-dev
Update version and copyright (compare)
nicksagona on 3.4.0
nicksagona on master
Update version and copyright (compare)
nicksagona on v3-dev
Update version and copyright (compare)
nicksagona on v5-dev
Update workflow Update workflow Update workflow and 24 more (compare)
nicksagona on 5.3.0
nicksagona on master
Update phpunit.xml (compare)
nicksagona on master
Update workflow (compare)
nicksagona on master
Workflow (compare)
nicksagona on master
Workflow (compare)
nicksagona on master
Change host for pgsql (compare)
nicksagona on master
Update workflow (compare)
nicksagona on master
Add postgres service to workflow (compare)
Route
class that acts like a custom service container of the router object for the application. With that, anywhere in the application you can do this:
$nick = new stdClass();
$nick->name = 'nick';
$jim = new stdClass();
$jim->name = 'jim';
$world = new stdClass();
$world->name = 'world';
$names = [$nick, $jim, $world];
foreach ($names as $name) {
echo '<a href="' . Route::url('hello', $name) . '">' . $name['name'] . '</a>';
}
<a href="/hello/nick">nick</a>
<a href="/hello/jim">jim</a>
<a href="/hello/world">world</a>
$user = Users::with('posts.comments')->getById(1001);
pop-db
v5.2.0
use Pop\Pdf\Pdf;
use Pop\Pdf\Document;
use Pop\Pdf\Document\Font;
use Pop\Pdf\Document\Page;
// Create text object
$string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec ligula ligula. Cras at dictum nibh. Nulla pulvinar accumsan arcu vitae vulputate. Cras pretium libero sit amet lobortis sagittis. Aliquam interdum vitae eros ut porttitor. Sed maximus purus vitae metus euismod imperdiet. Aliquam varius ultrices augue ut consequat. Aliquam feugiat ipsum eleifend ipsum vulputate feugiat. In posuere velit id magna porta viverra. Morbi diam mauris, porta eget felis ac, tincidunt malesuada dui. Donec vel urna id elit egestas vestibulum eget ac erat.';
$text = new Page\Text($string, 12);
// Add bounding alignment object
$text->setAlignment(Page\Text\Alignment::createCenter(50, 562, 15));
// Create a page and add the text to it
$page = new Page(Page::LETTER);
$page->addText($text, Font::ARIAL, 50, 650);
// Create a document, add the font to it and then the page
$document = new Document();
$document->addFont(new Font(Font::ARIAL));
$document->addPage($page);
// Pass the document to the Pdf object to build it and output it to HTTP
$pdf = new Pdf();
$pdf->outputToHttp($document);
$text->setAlignment(Page\Text\Alignment::createCenter(50, 562, 15));
$leftX
, $rightX
, and $leading
Hi - sure, you can just use the database adapter directly, via basic queries or prepared statements with bound parameters. Check out the docs here: https://pop-php-framework.readthedocs.io/en/latest/user_guide/databases.html#querying-a-database
Thanks Nick, but is there a way to avoid doing this:
$db = Pop\Db\Db::connect('mysql', $options);
I mean, a way to get the default database configuration instead of setting a config here
$application->services()->set('database', [
'call' => 'Pop\Db\Db::connect',
'params' => [
'adapter' => 'mysql',
'options' => $options
]
]);
$db = $application->services['database'];
@nicksagona
well a typical way to go is set the database as a service within the application. Have it wired up one time at the beginning of the app's lifecycle and then call that DB service as you need it. For example, you could have something like:
Ok, agreed...sorry for my insistence, but for example in app\src\Module.php there is:
public function register(Application $application)
{
parent::register($application);
if (isset($this->application->config['database'])) {
$this->initDb($this->application->config['database']);
}
if (null !== $this->application->router()) {
$this->application->router()->addControllerParams(
'*', [
'application' => $this->application,
'request' => new Request(),
'response' => new Response()
]
);
}
return $this;
}
I noticed:
$this->application->config['database']
is there a way to use something like this in my model?
well the model would have to be application-aware in order to access that. Either by passing the app object into the model's constructor, or into the method you're calling on the model.
Ok okay, in my case I need to do a complex query with joins to three MySQL VIEWs, which have no ID field. This Active Record implementation I don't think will allow me to do it with the query builder.