Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Phalcon\Tests\Integration\Mvc\Model; use Codeception\Example; use Integra..

Decoded Output download

<?php
 namespace Phalcon\Tests\Integration\Mvc\Model; use Codeception\Example; use IntegrationTester; use Phalcon\Mvc\Model\Criteria; use Phalcon\Mvc\Model\Query\Builder; use Phalcon\Mvc\Model\Resultset\Simple; use Phalcon\Tests\Fixtures\Traits\DiTrait; use Phalcon\Tests\Models\People; use Phalcon\Tests\Models\Personas; use Phalcon\Tests\Models\Personers; use Phalcon\Tests\Models\Robots; use Phalcon\Tests\Models\Users; use function cacheModelsDir; class CriteriaCest { use DiTrait; public function _before(IntegrationTester $I) { $this->setNewFactoryDefault(); $this->setDiMysql(); } public function _after(IntegrationTester $I) { $this->container["db"]->close(); } public function shouldExecuteInWhereQueryWithEmptyArray(IntegrationTester $I) { $criteria = Users::query()->inWhere(Users::class . ".id", array()); $I->assertEquals(Users::class . ".id != " . Users::class . ".id", $criteria->getWhere()); $I->assertInstanceOf(Simple::class, $criteria->execute()); } public function shouldCorrectHandleLimitAndOffset(IntegrationTester $I, Example $example) { $limit = $example[0]; $offset = $example[1]; $expected = $example[2]; $query = Users::query(); $query->limit($limit, $offset); $I->assertEquals($expected, $query->getLimit()); } private function getLimitOffset() : array { return array(array(-7, 0, array("number" => 7, "offset" => 0)), array("-7234", 0, array("number" => 7234, "offset" => 0)), array("18", 0, array("number" => 18, "offset" => 0)), array("18", 2, array("number" => 18, "offset" => 2)), array("-1000", -200, array("number" => 1000, "offset" => 200)), array("1000", "-200", array("number" => 1000, "offset" => 200)), array("0", "-200", null)); } public function createBuilderFromCriteria(IntegrationTester $I) { $criteria = Robots::query()->where("type='mechanical'"); $I->assertInstanceOf(Builder::class, $criteria->createBuilder()); } public function havingNotOverwritingGroupBy(IntegrationTester $I) { $query = Personas::query()->groupBy("estado")->having("SUM(cupo) > 1000000"); $I->assertEquals("estado", $query->getGroupBy()); $I->assertEquals("SUM(cupo) > 1000000", $query->getHaving()); } public function where(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado='I'")->execute(); $people = People::find("estado='I'"); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertInstanceOf(Simple::class, $personas); } public function whereRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $I->assertInstanceOf(Simple::class, Personers::query()->where("status='I'")->execute()); } public function conditions(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->conditions("estado='I'")->execute(); $people = People::find("estado='I'"); $I->assertEquals(count($personas->toArray()), count($people->toArray())); } public function conditionsRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $I->assertInstanceOf(Simple::class, Personers::query()->conditions("status='I'")->execute()); } public function whereOrderBy(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado='A'")->orderBy("nombres")->execute(); $people = People::find(array("estado='A'", "order" => "nombres")); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function whereOrderByRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personers = Personers::query()->where("status='A'")->orderBy("navnes")->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function whereOrderByLimit(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado='A'")->orderBy("nombres")->limit(100)->execute(); $people = People::find(array("estado='A'", "order" => "nombres", "limit" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function whereOrderByLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personers = Personers::query()->where("status='A'")->orderBy("navnes")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function bindParamsWithLimit(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado=?1")->bind(array(1 => "A"))->orderBy("nombres")->limit(100)->execute(); $people = People::find(array("estado=?1", "bind" => array(1 => "A"), "order" => "nombres", "limit" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function bindParamsWithOrderAndLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personers = Personers::query()->where("status=?1")->bind(array(1 => "A"))->orderBy("navnes")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function bindParamsAsPlaceholdersWithOrderAndLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personers = Personers::query()->where("status=:status:")->bind(array("status" => "A"))->orderBy("navnes")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function limitWithOffset(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado=?1")->bind(array(1 => "A"))->orderBy("nombres")->limit(100, 10)->execute(); $people = People::find(array("estado=?1", "bind" => array(1 => "A"), "order" => "nombres", "limit" => array("number" => 100, "offset" => 10))); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function bindOrderLimit(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->where("estado=:estado:")->bind(array("estado" => "A"))->orderBy("nombres")->limit(100)->execute(); $people = People::find(array("estado=:estado:", "bind" => array("estado" => "A"), "order" => "nombres", "limit" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function orderBy(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $personas = Personas::query()->orderBy("nombres"); $I->assertEquals("nombres", $personas->getOrderBy()); } public function freshCache(IntegrationTester $I, Example $example) { $this->container->setShared("db", $example["adapter"]); $cache = $this->getAndSetModelsCacheStream(); $cache->clear(); $personas = Personas::query()->where("estado='I'")->cache(array("key" => "cache-for-issue-2131"))->execute(); $I->assertTrue($personas->isFresh()); $personas = Personas::query()->where("estado='I'")->cache(array("key" => "cache-for-issue-2131"))->execute(); $I->assertFalse($personas->isFresh()); $I->amInPath(cacheModelsDir()); $I->safeDeleteFile("cache-for-issue-2131"); $I->dontSeeFileFound("cache-for-issue-2131"); } protected function adapterProvider() : array { return array(array("adapter" => $this->newDiMysql()), array("adapter" => $this->newDiSqlite()), array("adapter" => $this->newDiPostgresql())); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Phalcon\Tests\Integration\Mvc\Model; use Codeception\Example; use IntegrationTester; use Phalcon\Mvc\Model\Criteria; use Phalcon\Mvc\Model\Query\Builder; use Phalcon\Mvc\Model\Resultset\Simple; use Phalcon\Tests\Fixtures\Traits\DiTrait; use Phalcon\Tests\Models\People; use Phalcon\Tests\Models\Personas; use Phalcon\Tests\Models\Personers; use Phalcon\Tests\Models\Robots; use Phalcon\Tests\Models\Users; use function cacheModelsDir; class CriteriaCest { use DiTrait; public function _before(IntegrationTester $I) { $this->setNewFactoryDefault(); $this->setDiMysql(); } public function _after(IntegrationTester $I) { $this->container["\144\142"]->close(); } public function shouldExecuteInWhereQueryWithEmptyArray(IntegrationTester $I) { $criteria = Users::query()->inWhere(Users::class . "\x2e\x69\x64", array()); $I->assertEquals(Users::class . "\x2e\151\144\x20\x21\75\x20" . Users::class . "\56\x69\144", $criteria->getWhere()); $I->assertInstanceOf(Simple::class, $criteria->execute()); } public function shouldCorrectHandleLimitAndOffset(IntegrationTester $I, Example $example) { $limit = $example[0]; $offset = $example[1]; $expected = $example[2]; $query = Users::query(); $query->limit($limit, $offset); $I->assertEquals($expected, $query->getLimit()); } private function getLimitOffset() : array { return array(array(-7, 0, array("\x6e\x75\155\142\x65\162" => 7, "\157\146\146\163\145\164" => 0)), array("\55\x37\x32\63\64", 0, array("\156\165\155\142\145\x72" => 7234, "\x6f\x66\x66\x73\x65\x74" => 0)), array("\x31\70", 0, array("\x6e\165\155\142\145\x72" => 18, "\x6f\x66\146\x73\145\164" => 0)), array("\61\70", 2, array("\156\165\x6d\142\145\x72" => 18, "\x6f\146\x66\x73\x65\x74" => 2)), array("\55\x31\x30\60\60", -200, array("\156\x75\x6d\142\145\162" => 1000, "\x6f\x66\x66\163\x65\164" => 200)), array("\x31\60\x30\60", "\55\x32\60\x30", array("\x6e\x75\155\x62\145\x72" => 1000, "\157\x66\146\163\145\164" => 200)), array("\x30", "\x2d\x32\x30\x30", null)); } public function createBuilderFromCriteria(IntegrationTester $I) { $criteria = Robots::query()->where("\x74\x79\160\x65\75\x27\155\145\x63\150\x61\x6e\x69\143\141\154\x27"); $I->assertInstanceOf(Builder::class, $criteria->createBuilder()); } public function havingNotOverwritingGroupBy(IntegrationTester $I) { $query = Personas::query()->groupBy("\145\x73\164\x61\144\157")->having("\x53\125\x4d\x28\143\x75\x70\157\51\40\x3e\40\61\60\60\60\x30\x30\60"); $I->assertEquals("\x65\x73\164\x61\x64\157", $query->getGroupBy()); $I->assertEquals("\x53\x55\x4d\50\143\165\x70\x6f\x29\40\x3e\x20\x31\x30\60\60\60\x30\60", $query->getHaving()); } public function where(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\x62", $example["\x61\144\x61\160\x74\145\x72"]); $personas = Personas::query()->where("\x65\163\x74\x61\x64\157\75\47\111\47")->execute(); $people = People::find("\145\x73\x74\x61\x64\x6f\75\47\x49\47"); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertInstanceOf(Simple::class, $personas); } public function whereRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\x62", $example["\141\x64\141\160\164\145\162"]); $I->assertInstanceOf(Simple::class, Personers::query()->where("\163\x74\x61\164\x75\x73\x3d\x27\x49\x27")->execute()); } public function conditions(IntegrationTester $I, Example $example) { $this->container->setShared("\144\x62", $example["\141\144\x61\x70\x74\145\x72"]); $personas = Personas::query()->conditions("\x65\x73\164\141\x64\x6f\x3d\47\x49\x27")->execute(); $people = People::find("\145\163\x74\141\x64\x6f\x3d\47\x49\x27"); $I->assertEquals(count($personas->toArray()), count($people->toArray())); } public function conditionsRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\144\142", $example["\141\x64\x61\160\x74\x65\x72"]); $I->assertInstanceOf(Simple::class, Personers::query()->conditions("\163\x74\141\x74\165\x73\x3d\47\111\x27")->execute()); } public function whereOrderBy(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\x61\144\141\160\164\x65\x72"]); $personas = Personas::query()->where("\x65\x73\164\x61\x64\x6f\75\47\x41\47")->orderBy("\156\x6f\155\x62\x72\x65\163")->execute(); $people = People::find(array("\145\x73\x74\x61\144\157\75\x27\x41\x27", "\157\x72\x64\145\162" => "\x6e\x6f\x6d\142\x72\x65\163")); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function whereOrderByRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\x62", $example["\x61\144\141\x70\164\145\162"]); $personers = Personers::query()->where("\x73\164\x61\164\x75\x73\75\x27\x41\x27")->orderBy("\156\141\x76\x6e\x65\163")->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function whereOrderByLimit(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\141\x64\x61\160\x74\x65\162"]); $personas = Personas::query()->where("\145\163\164\141\x64\157\x3d\47\x41\x27")->orderBy("\x6e\157\155\142\162\x65\x73")->limit(100)->execute(); $people = People::find(array("\145\163\164\141\x64\x6f\75\x27\101\47", "\157\x72\x64\145\x72" => "\156\157\155\142\162\x65\163", "\154\x69\x6d\x69\164" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function whereOrderByLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\144\142", $example["\x61\x64\141\x70\164\x65\x72"]); $personers = Personers::query()->where("\x73\164\141\x74\x75\x73\75\47\x41\x27")->orderBy("\156\141\x76\x6e\145\163")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function bindParamsWithLimit(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\141\144\141\x70\164\145\162"]); $personas = Personas::query()->where("\145\163\164\x61\144\157\75\77\x31")->bind(array(1 => "\101"))->orderBy("\156\x6f\x6d\142\x72\x65\163")->limit(100)->execute(); $people = People::find(array("\145\x73\164\x61\x64\x6f\75\77\x31", "\x62\x69\156\144" => array(1 => "\101"), "\x6f\x72\144\x65\162" => "\x6e\157\155\142\162\145\163", "\154\151\x6d\151\x74" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function bindParamsWithOrderAndLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\141\x64\141\160\164\145\162"]); $personers = Personers::query()->where("\x73\x74\x61\x74\x75\x73\x3d\77\x31")->bind(array(1 => "\101"))->orderBy("\156\x61\166\x6e\145\163")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function bindParamsAsPlaceholdersWithOrderAndLimitRenamed(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\x61\x64\x61\160\x74\145\162"]); $personers = Personers::query()->where("\x73\164\141\x74\x75\163\75\x3a\x73\164\x61\164\x75\163\x3a")->bind(array("\x73\x74\x61\x74\x75\163" => "\101"))->orderBy("\x6e\x61\x76\x6e\x65\x73")->limit(100)->execute(); $I->assertInstanceOf(Simple::class, $personers); $I->assertInstanceOf(Personers::class, $personers->getFirst()); } public function limitWithOffset(IntegrationTester $I, Example $example) { $this->container->setShared("\144\142", $example["\141\144\141\x70\x74\x65\162"]); $personas = Personas::query()->where("\x65\x73\164\141\144\157\75\77\x31")->bind(array(1 => "\101"))->orderBy("\156\157\155\142\x72\145\163")->limit(100, 10)->execute(); $people = People::find(array("\145\x73\164\x61\x64\x6f\75\x3f\x31", "\142\151\156\x64" => array(1 => "\x41"), "\x6f\162\144\145\x72" => "\156\157\x6d\x62\162\145\163", "\x6c\151\155\151\164" => array("\156\165\x6d\x62\145\162" => 100, "\x6f\x66\146\163\145\164" => 10))); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function bindOrderLimit(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\x62", $example["\141\x64\141\x70\x74\145\x72"]); $personas = Personas::query()->where("\x65\163\164\x61\x64\157\x3d\72\x65\163\x74\x61\144\x6f\x3a")->bind(array("\x65\163\x74\141\x64\x6f" => "\x41"))->orderBy("\x6e\157\x6d\x62\x72\x65\163")->limit(100)->execute(); $people = People::find(array("\145\x73\164\x61\x64\x6f\75\x3a\145\x73\x74\141\144\x6f\x3a", "\x62\151\156\144" => array("\x65\x73\164\x61\x64\x6f" => "\101"), "\x6f\162\x64\145\162" => "\x6e\157\x6d\142\x72\145\163", "\154\151\x6d\x69\x74" => 100)); $I->assertEquals(count($personas->toArray()), count($people->toArray())); $I->assertEquals($personas->getFirst()->cedula, $people->getFirst()->cedula); } public function orderBy(IntegrationTester $I, Example $example) { $this->container->setShared("\x64\142", $example["\141\144\141\x70\x74\145\x72"]); $personas = Personas::query()->orderBy("\x6e\x6f\x6d\x62\162\x65\163"); $I->assertEquals("\x6e\x6f\x6d\142\162\x65\163", $personas->getOrderBy()); } public function freshCache(IntegrationTester $I, Example $example) { $this->container->setShared("\144\142", $example["\141\144\141\x70\x74\145\162"]); $cache = $this->getAndSetModelsCacheStream(); $cache->clear(); $personas = Personas::query()->where("\145\163\x74\141\144\x6f\x3d\x27\111\47")->cache(array("\153\145\171" => "\x63\x61\143\x68\x65\x2d\146\x6f\x72\55\151\163\163\x75\x65\x2d\x32\61\x33\x31"))->execute(); $I->assertTrue($personas->isFresh()); $personas = Personas::query()->where("\x65\163\x74\x61\x64\x6f\75\x27\111\x27")->cache(array("\153\145\171" => "\x63\141\x63\150\x65\55\146\157\x72\x2d\151\163\x73\x75\x65\x2d\x32\61\63\x31"))->execute(); $I->assertFalse($personas->isFresh()); $I->amInPath(cacheModelsDir()); $I->safeDeleteFile("\x63\141\x63\150\x65\x2d\x66\x6f\x72\x2d\151\163\x73\x75\x65\55\62\x31\x33\61"); $I->dontSeeFileFound("\143\x61\143\x68\145\55\x66\x6f\162\55\x69\163\163\165\145\x2d\x32\61\63\x31"); } protected function adapterProvider() : array { return array(array("\141\144\141\x70\x74\x65\x72" => $this->newDiMysql()), array("\x61\144\x61\x70\x74\145\162" => $this->newDiSqlite()), array("\141\x64\141\x70\x74\x65\x72" => $this->newDiPostgresql())); } }

Function Calls

None

Variables

None

Stats

MD5 dac392abdc88e8182daf60901712f52e
Eval Count 0
Decode Time 85 ms