1. Go to this page and download the library: Download hwalde/pooq library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$f = Forum::as('f');
$t = Thread::as('t');
$resultList = select($f, $t->title()) // Select all fields of Forum and the title field of Thread
->from($t)
->innerJoin($f)->on($f->forumid()->eq($t->forumid())) // "INNER JOIN forum f ON `f`.`forumid` = `t`.`forumid`"
->fetchAll(); // Executes the query and returns ResultList
/** @var ThreadRecord[] $threadRecordList */
$threadRecordList = $resultList->into($t); // Maps all Thread fields of ResultList into ThreadRecordList
foreach($threadList as $thread) { // for each row
echo $thread->getTitle(); // output the title
}
// note: this is only supported for tables containing a primary-key
$record->refresh(); // Reload the record from the database
$record->store(); // insert or update the record to the database
$record->delete(); // deletes this record in the database
$array = $recordList->toAssoc(); // Maps entire record-list
$array = $record->toAssoc(); // Maps only a single record
update(Forum::class)
->set(Forum::title(), 'New title')
->set(Forum::description(), 'Lorem ipsum ..')
->where(Forum::forumId()->eq(value(123)))
->execute();
$config = new \POOQ\CodeGeneration\CodeGeneratorConfig(__DIR__.DIRECTORY_SEPARATOR.'gensrc');
$config->setCopyrightInformation(
<<<END
/**
* Your custom copyright text!
*/
END
);
// This is optional:
$config->setNameMap(
[
// column or tablename => camel-case-name starting lowercase
'userid' => 'userId',
'display_order' => 'displayOrder',
'accessmask' => 'accessMask',
'product' => 'product',
]
);
// This is optional:
$businesslogicFolderPath = __DIR__.'/test/businesslogic';
$config->setModelName2NamespaceMap(new \POOQ\CodeGeneration\ModelName2NamespaceMap(
[
// Name of model class => NamespaceObject-object
'Post' => new \POOQ\CodeGeneration\NamespaceObject(
'businesslogic\\post',
$businesslogicFolderPath.'/post'
),
'Forum' => new \POOQ\CodeGeneration\NamespaceObject(
'businesslogic\\forum',
$businesslogicFolderPath.'/forum'
),
]
));
$generator = new \POOQ\CodeGeneration\CodeGenerator($config);
$generator->convertDatabase('database_name', 'username', 'password', 'hostname', 3306);
sql
SELECT `t`.`title` as `title`, `t`.`lastposter` as `lastposter`, `t`.`postusername` as `postusername`, `t`.`replycount` as `replycount`, `t`.`threadid` as `threadid`
FROM thread t
WHERE `t`.`forumid` = 2
ORDER BY `t`.`threadid` DESC
LIMIT 10
OFFSET 0
sql
SELECT `thread`.`title` as `title`, `thread`.`lastposter` as `lastposter`
FROM `thread`
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.