PHP code example of christianklisch / ckdb
1. Go to this page and download the library: Download christianklisch/ckdb 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/ */
christianklisch / ckdb example snippets
$em = new CKDB($config);
$config = array(
'entitypaths' => array('path/to/your/entities'),
'databasepath' => 'database',
'compression' => 1,
);
$em = new CKDB($config);
$primkeys = array(
'User' => 'id'
);
$em->setPrimaryKeys($primkeys);
$forkeys = array(
'User' => array('id', 'firstname', 'email')
);
$em->setForeignKeys($forkeys);
$refclasses = array(
'User' => array('homeaddress' => 'Address')
);
$em->setReferenceClasses($refclasses);
$u = new User();
$u->setId('4711');
$u->setFirstname('George');
$u->setEmail('[email protected] ');
$em->persist($u);
$em->remove($u);
$em->reIndex('User');
$userRepository = $em->getRepository('User')
$userRepository->find()->equals(array('firstname' => 'George'))->gt(array('age' => '50'))->sortBy('age', SORT_DESC)->getResult();
$userRepository->find()->in('firstname', array('Martin','George'))->getResult();
$fathers = $userRepository->find()->equals(array('firstname' => 'Mo', 'lastname' => 'Miller'))->getResult();
$userRepository->find()->in('father', $fathers)->getResult();
$userRepository->find()->gt(array('age' => '50'))->sortBy('age', SORT_DESC)->getResult();