This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Classe Helper, auxilia na geração de tags HTML para formulários no padrão do framework Bootstrap | |
* | |
* @author Valdirene da Cruz Neves Júnior <[email protected]> | |
* @version 2 | |
* | |
*/ | |
class BForm extends Html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CharacterParser | |
{ | |
private $charaters = array( | |
'a' => 'ka', | |
'b' => 'tu', | |
'c' => 'mi', | |
'd' => 'te', | |
'e' => 'ku', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @FileName AS VARCHAR(30), @FullPath AS VARCHAR(200), @Database sysname; | |
SET @Database = 'MyDatabaseName'; | |
SET @FileName = CONVERT(VARCHAR(30), GETDATE(), 20); | |
SET @FileName = REPLACE(@FileName, '-', ''); | |
SET @FileName = REPLACE(@FileName, ' ', ''); | |
SET @FileName = REPLACE(@FileName, ':', ''); | |
SET @FileName = @Database + '_' + @FileName + '.bak'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Pais extends Model | |
{ | |
public static function listarArray() | |
{ | |
$paises = array(); | |
foreach(self::search(1, 1000, 'Nome') as $pais) | |
{ | |
$paises[$pais->Id] = $pais->Nome; //troque pelos nomes das suas colunas |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `posts` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`title` varchar(128) NOT NULL, | |
`date` datetime NOT NULL, | |
`content` text NOT NULL, | |
PRIMARY KEY (`id`) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Entities; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="posts") | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->get('/posts', function () use ($app) { | |
$em = $app['orm.em']; | |
$results = $em->getRepository('App\Entities\Post')->findAll(); | |
$hydrator = new CollectionExtractor(new DoctrineHydrator($em)); | |
return $app->json($hydrator->extract($results)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->get('/posts/{id}', function ($id) use ($app) { | |
$em = $app['orm.em']; | |
$post = $em->getRepository('App\Entities\Post')->find($id); | |
$hydrator = new DoctrineHydrator($em); | |
return $app->json($hydrator->extract($post)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->post('/posts', function (Request $request) use ($app) { | |
$post = new Post(); | |
$post->setTitle($request->get('title')); | |
$post->setContent($request->get('content')); | |
$em = $app['orm.em']; | |
$em->persist($post); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->put('/posts/{id}', function ($id, Request $request) use ($app) { | |
$em = $app['orm.em']; | |
$post = $em->getRepository('App\Entities\Post')->find($id); | |
$post->setTitle($request->get('title')); | |
$post->setContent($request->get('content')); | |
$em->persist($post); |
OlderNewer