$str_1 = 'mais'; $str_2 = 'blu'; echo $str_1.$str_2; // maisblu
$str = 'mais'; echo $str.' blu'; // mais blu
$str_1 = 'mais'; $str_2 = 'blu'; echo $str_1.$str_2; // maisblu
$str = 'mais'; echo $str.' blu'; // mais blu
<?php $i = 1; echo $i++; // 1 $i = 1; echo ++$i; // 2 $i = 'php'; echo ++$i; // phq $i = (string)'php'; $i = (integer)$i; // string to integer = 0 echo ++$i; // 1
$var = 'good'; $_var = 'good'; $1var = 'bad'; $_1var = 'good';
$var= 'mais'; $$var = 'blu'; echo $mais; // blu
boolean false => false boolean true => true integer 0 => false integer 1 => true string 0000 => true string 1111 => true integer 0 => false integer 1111 => true double 0.1 => true double 1.1 => true string test => true string 0 => false
definir une variable
{% set foo = bar %}if/else
{% if var == true %}
{{ var }} = true
{% else %}
{{ var }} != true
{% endif %}for
{% for row in rows %}
{{ row }}
{% endfor %}1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | Doctrine\Tests\ORM\Mapping\User:
type: entity
table: cms_users
namedQueries:
all: SELECT u FROM __CLASS__ u
id:
id:
type: integer
generator:
strategy: AUTO
sequenceGenerator:
sequenceName: tablename_seq
allocationSize: 100
initialValue: 1
fields:
name:
type: string
length: 50
nullable: true
unique: true
email:
type: string
column: user_email
columnDefinition: CHAR(32) NOT NULL
oneToOne:
address:
targetEntity: Address
inversedBy: user
joinColumn:
name: address_id
referencedColumnName: id
onDelete: CASCADE
onUpdate: CASCADE
cascade: [ remove ]
oneToMany:
phonenumbers:
targetEntity: Phonenumber
orphanRemoval: true
mappedBy: user
orderBy:
number: ASC
cascade: [ persist ]
manyToMany:
groups:
targetEntity: Group
joinTable:
name: cms_users_groups
joinColumns:
user_id:
referencedColumnName: id
nullable: false
unique: false
inverseJoinColumns:
group_id:
referencedColumnName: id
columnDefinition: INT NULL
cascade:
- all
lifecycleCallbacks:
prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ]
postPersist: [ doStuffOnPostPersist ]
uniqueConstraints:
search_idx:
columns: name,user_email
indexes:
name_idx:
columns: name
0:
columns: user_email |
$this->getContainer()->getParameter('extension'); $this->getContainer()->getParameter('row_by_page'); $this->getContainer()->getParameter('kernel.environment');
Strings
string (used for shorter strings) text (used for larger strings) Numbers integer smallint bigint decimal float
Dates and Times (use a DateTime object for these fields in PHP)
date time datetime
Other Types
boolean object (serialized and stored in a CLOB field) array (serialized and stored in a CLOB field)
php app/console generate:bundle --namespace=Gallery/AlbumBundle --format=yml php app/console doctrine:database:create php app/console doctrine:generate:entity --entity="GalleryAlbumBundle:Album" --fields="name:string(255) description:text" php app/console doctrine:generate:entities Gallery php app/console doctrine:generate:entities GalleryAlbumBundle php app/console doctrine:generate:entities Gallery/AlbumBundle/Entity/Album php app/console doctrine:schema:update --force
#!/usr/bin/python # -*- coding: utf-8 -*- import os import mimetypes import string import sys import shutil import getopt import re class main: def usage(self): print('%s %s dir te explore'%('-i', '--indir')) print('%s %s playlist output'%('-p', '--playlist')) print('exemple: %s %s %s'%(__file__, '--indir=/var/www/mp3', '-p ./blu.xml')) def __init__(self, argv): self.indir = 0 self.playlist = 'playlist.xml' try: opts, args = getopt.getopt(argv, "i:p", ["indir=", "playlist="]) except getopt.GetoptError: self.usage() sys.exit(2) for opt, arg in opts: if opt in ('-i', '--indir'): if(os.path.exists(arg) == 0): sys.exit(1) print('walk %s'%(arg)) self.indir = arg elif opt in ('-p', '--playlist'): print('playlist %s'%(arg)) self.playlist = arg if self.indir != 0: self.run() else: self.usage() def strReplace(self, str, array): for search, replace in array: str = str.replace(search, replace) return str def _human_key(self, key): parts = re.split('(\d*\.\d+|\d+)', key) return tuple((e.swapcase() if i % 2 == 0 else float(e)) for i, e in enumerate(parts)) def run(self): print 'run' xml = '<?xml version="1.0" encoding="UTF-8"?>\n' xml += '<playlist version="1" xmlns="http://xspf.org/ns/0/">\n' xml += '<title>'+os.path.split(self.playlist)[1].replace('_', ' ').replace('.xml', '')+'</title>\n' xml += '<creator>Bayard</creator>\n' xml += '<link></link>\n' xml += '<info></info>\n' xml += '<image></image>\n' xml += '<trackList>\n' for dirpath, dirnames, filenames in os.walk(self.indir): c = os.path.split(dirpath)[1] filenames.sort(key=self._human_key) for filename in filenames: print dirpath+'/'+filename newfilename = self.strReplace(filename, [(' ', '_'), ('–', '-')]); fo_path = os.path.join(dirpath, filename) fn_path = os.path.join(dirpath, newfilename) f_mime = mimetypes.guess_type(fo_path) if(os.path.exists(fn_path) == 0): print('%s move to %s'%(fo_path, fn_path)) shutil.move(fo_path, fn_path) if f_mime[0] == 'audio/mpeg': xml += ' <track>\n' xml += ' <title>'+newfilename.replace('_', ' ').replace('.mp3', '')+'</title>\n'; xml += ' <location>http://bayardmusique.bayardcdn.com/'+c+'/'+filename+'</location>\n'; xml += ' </track>\n' xml += '</trackList>\n' xml += '</playlist>' self.write(xml) def write(self, xml): print('write %s'%(self.playlist)) f = open(self.playlist, 'w') f.write(xml) f.close() if __name__ == "__main__": main(sys.argv[1:])