1. Go to this page and download the library: Download shedeza/sybase-orm 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/ */
use SybaseORM\Cache\RedisCacheAdapter;
$redis = new \Redis();
$redis->connect('127.0.0.1');
$em = OrmFactory::create([
'connection' => $connectionConfig,
'entity_directories' => [__DIR__ . '/src/Entity'],
'second_level_cache' => new RedisCacheAdapter($redis),
]);
use SybaseORM\Query\Criteria\Criteria;
$criteria = Criteria::create()
->where(Criteria::expr()->eq('status', 'active'))
->andWhere(Criteria::expr()->in('role', ['admin', 'manager']))
->orderBy(['createdAt' => Criteria::DESC])
->setFirstResult(0)
->setMaxResults(10);
// Ejecuta la consulta usando el QueryBuilder subyacente
$users = $entityManager->getRepository(User::class)->matching($criteria);
namespace App\Fixture;
use SybaseORM\Fixture\FixtureInterface;
use SybaseORM\ORM\EntityManagerInterface;
use App\Entity\User;
class UserFixture implements FixtureInterface {
public function load(EntityManagerInterface $em): void {
$user = new User();
$user->email = '[email protected]';
$user->status = 'active';
$em->persist($user);
// NOTA: No es necesario hacer $em->flush(), el FixtureLoader lo hace automáticamente al final.
}
}
bash
# Ejecutar todos los fixtures en database/seeds/
php bin/sybase-orm orm:db:seed --dir=database/seeds
# O especificar una clase directamente
php bin/sybase-orm orm:db:seed --class="App\Fixture\UserFixture"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.