Diferencia entre revisiones de «Cheat sheet beta1»

De KumbiaPHP Framework Wiki
(Página creada con 'Hoja de ayuda para la versión 1.0 beta1 (Spirit) Recordemos que esta hoja de ayuda va para la version 1.0 beta1 Aqui definimos el orden del contenido para luego pasarlo a un P...')
 
 
(No se muestran 2 ediciones intermedias del mismo usuario)
Línea 4: Línea 4:
 
Aqui definimos el orden del contenido para luego pasarlo a un PDF o PNG los colores y fuentes no importan, solo el que esten completos, buena sintaxis y en el orden adecuado
 
Aqui definimos el orden del contenido para luego pasarlo a un PDF o PNG los colores y fuentes no importan, solo el que esten completos, buena sintaxis y en el orden adecuado
  
 +
[[Archivo:Chuleta.jpg]]
  
== Clases ==
 
  
 +
Aqui esta el contenido de la chuleta; usenlo para crear sus propias versiones :)
 +
 +
 +
Clases
 
Load::lib(string $nombre)
 
Load::lib(string $nombre)
 
Load::model(string $nombre)
 
Load::model(string $nombre)
Línea 21: Línea 25:
 
Session::isset_data(string $nombre)
 
Session::isset_data(string $nombre)
  
Upload::file_in_path(string $nombre, string $path, string $nuevo_nombre)
 
 
Upload::file(string $nombre, string $nuevo_nombre)
 
 
Upload::image(string $nombre, string $nuevo_nombre)
 
  
 +
Upload::file_in_path(string $nombre, string $path, string $nuevo_nombre)
 +
Upload::file(string $nombre, string $nuevo_nombre)
 +
Upload::image(string $nombre, string $nuevo_nombre)
  
  
== Filter ==
+
Filter  
  
  
 
+
Add_filter($filter)  
Add_filter($filter)
+
Apply($var, [filters]) y apply_filter($var, [filters])  
 
+
Get_instance()  
Apply($var, [filters]) y apply_filter($var, [filters])
 
 
 
Get_instance()
 
  
 
aqui faltan mas y en la wiki tambien; tambien tengo dudas si los de abajo estan en la beta1
 
aqui faltan mas y en la wiki tambien; tambien tengo dudas si los de abajo estan en la beta1
  
Filter::get(mixed $s, array $opciones)
 
 
Filter::get_array($array, array $opciones)
 
 
Filter::get_object($object, array $opciones)
 
 
 
=== Filtros ===
 
 
addslashes
 
 
alnum
 
 
alpha
 
 
date
 
 
digits
 
 
htmlentities
 
 
htmlspecialchars
 
 
int
 
 
ipv4
 
 
lower
 
 
md5
 
 
nl2br
 
 
numeric
 
 
stripslashes
 
  
stripspace
+
Filter::get(mixed $s, array $opciones)
 +
Filter::get_array($array, array $opciones)
 +
Filter::get_object($object, array $opciones)
  
striptags
+
Filtros
 +
addslashes
 +
alnum
 +
alpha
 +
date
 +
digits
 +
htmlentities
 +
htmlspecialchars
 +
int
 +
ipv4
 +
lower
 +
md5
 +
nl2br
 +
numeric
 +
stripslashes
 +
stripspace
 +
striptags  
 +
trim
 +
upper
  
trim
 
 
upper
 
 
 
 
== Paths ==
 
  
 +
Paths
 
APP
 
APP
 
APP_PATH
 
APP_PATH
Línea 96: Línea 73:
 
APP_CHARSET
 
APP_CHARSET
 
URL_PATH
 
URL_PATH
APP_CHARSET
 
  
  
== Helpers ==
+
Constante Descripción
 +
APP Nombre de la Aplicación
 +
APP_PATH ruta absoluta de la aplicación (/path/to/app/)
 +
CORE_PATH ruta absoluta del core (/path/to/core/)
 +
PUBLIC_PATH
 +
URL_PATH
 +
APP_CHARSET
  
 +
Helpers
  
form_tag(string $action)
+
form_tag(string $action)
 +
text_field_tag($nombre)
 +
textarea_tag($nombre)
 +
password_field_tag($nombre)
 +
hidden_field_tag($name)
 +
checkbox_field_tag($nombre)
 +
radio_field_tag($nombre, $lista)
 +
date_field_tag($nombre)
 +
file_field_tag($nombre)
 +
upload_image_tag($nombre)
 +
select_tag($name, $lista)
 +
button_tag($caption)
 +
submit_image_tag($caption, $src)
 +
submit_tag($caption)
 +
end_form_tag()  
  
text_field_tag($nombre)
+
img_tag(string $src)  
 
+
swf_tag(string $src)  
textarea_tag($nombre)
+
comillas($texto)  
 
 
password_field_tag($nombre)
 
 
 
hidden_field_tag($name)
 
 
 
checkbox_field_tag($nombre)
 
 
 
radio_field_tag($nombre, $lista)
 
 
 
date_field_tag($nombre)
 
 
 
file_field_tag($nombre)
 
 
 
upload_image_tag($nombre)
 
 
 
select_tag($name, $lista)
 
 
 
button_tag($caption)
 
 
 
submit_image_tag($caption, $src)
 
 
 
submit_tag($caption)
 
 
 
end_form_tag()
 
 
 
 
 
img_tag(string $src)
 
 
 
swf_tag(string $src)
 
 
 
comillas($texto)
 
  
 
render_partial(string $nombre)
 
render_partial(string $nombre)
 
link_to(string $url, string $texto)
 
link_to(string $url, string $texto)
  
javascript_include_tag($archivo_js)
 
  
javascript_library_tag($archivo_js)
+
javascript_include_tag($archivo_js)
 +
javascript_library_tag($archivo_js)
 +
stylesheet_link_tag($archivo_css, [use_variables: true])  
  
stylesheet_link_tag($archivo_css, [use_variables: true])
 
 
 
 
== Controller ==
 
 
 
=== Metodos ===
 
  
 +
Controller
 +
Metodos
  
 
render(string $view)
 
render(string $view)
 
post(array $valor)
 
post(array $valor)
get(array $valor)
+
get(array $valor)  
 
+
request($valor)  
request($valor)
+
route_to([params: valor])  
 
+
redirect(string $controlador, integer $segundos)  
route_to([params: valor])
+
cache_layout(integer $minutos)  
 
+
not_found(string $controller, string $action)  
redirect(string $controlador, integer $segundos)
+
set_response(string $tipo)  
 
+
is_alnum($valor)  
cache_layout(integer $minutos)
+
load_record($registro)  
 
+
is_numeric($valor)  
not_found(string $controller, string $action)
 
 
 
set_response(string $tipo)
 
 
 
is_alnum($valor)
 
 
 
load_record($registro)
 
 
 
is_numeric($valor)
 
 
 
  
 
has_post(string $nombre) //Verifica si existe una variable dentro del array $_POST
 
has_post(string $nombre) //Verifica si existe una variable dentro del array $_POST
Línea 183: Línea 134:
 
has_request(string $nombre) //Verifica si existe una variable dentro del array $_REQUEST
 
has_request(string $nombre) //Verifica si existe una variable dentro del array $_REQUEST
  
set_persistent(string $nombre, $valor) //hace persistente valores para el controlador actual
 
  
get_persistent(string $nombre) //Recupera el el valor persistente
+
set_persistent(string $nombre, $valor) //hace persistente valores para el controlador actual
 +
get_persistent(string $nombre) //Recupera el el valor persistente
 +
destroy_persistent(string $nombre) //destruye el valor persistente  
  
destroy_persistent(string $nombre) //destruye el valor persistente
 
  
 +
Propiedades
 +
$action_name -» Nombre de la accion actual
 +
$controller_name -» Nnmbre del controller actual
 +
$template -» Nombre del template a usar
 +
$debug -» Activacion del modo Debug
  
  
http://wiki.kumbiaphp.com/skins/common/images/button_headline.png
 
=== Propiedades ===
 
  
$action_name -> Nombre de la accion actual
+
Filtros  
$controller_name -> Nnmbre del controller actual
 
$template -> Nombre del template a usar
 
$debug -> Activacion del modo Debug
 
 
 
 
 
Filtros
 
 
before_filter()
 
before_filter()
 
after_filter()
 
after_filter()
Línea 206: Línea 154:
  
  
== Models ==
+
Models  
ACTIVE RECORD
+
ACTIVE RECORD  
 
 
 
 
=== Consultas ===
 
  
 +
Consultas
  
 
distinct([string $atributo_entidad], [“conditions: …], [“order: …”], [“limit: …“], [“columns: …”])
 
distinct([string $atributo_entidad], [“conditions: …], [“order: …”], [“limit: …“], [“columns: …”])
Línea 223: Línea 169:
 
find_by_*campo*(string $valor)
 
find_by_*campo*(string $valor)
 
find_all_by_*campo*(string $valor)
 
find_all_by_*campo*(string $valor)
sql (string $sql)
+
 
 +
sql (string $sql)  
 +
 
 
--------------------------------------------------
 
--------------------------------------------------
 +
 
count(string $condicion)
 
count(string $condicion)
 
count_by_sql(string $sql)
 
count_by_sql(string $sql)
 
sum(string $campo, [“conditions: …”])
 
sum(string $campo, [“conditions: …”])
 +
 
--------------------------------------------------
 
--------------------------------------------------
 +
 
average(string $campo, [“conditions: …”])
 
average(string $campo, [“conditions: …”])
 
maximum(string $campo, [“conditions: …”])
 
maximum(string $campo, [“conditions: …”])
 
minimum(string $campo, [“conditions: …”])
 
minimum(string $campo, [“conditions: …”])
 +
 
--------------------------------------------------
 
--------------------------------------------------
create()
+
 
update()
+
 
update_all( [“conditions: …”])
+
create()  
 +
update()  
 +
update_all( [“conditions: …”])  
 
save()
 
save()
create_from_request()
+
create_from_request()  
save_from_request()
+
save_from_request()  
delete(integer $id)
+
delete(integer $id)  
delete_all()
+
delete_all()  
 +
 
  
 +
Validaciones
  
=== Validaciones ===
+
validates_presence_of(string $campo)
 +
validates_length_of(string $campo,  [“parametros: …”])
 +
validates_numericality_of(string $campo)
 +
validates_email_in(string $campo)
 +
validates_uniqueness_of(string $campo)
 +
validates_date_in(string $campo)
 +
validates_format_of(string $campo, string $expresion_regular)
  
validates_presence_of(string $campo)
+
Parametros
validates_length_of(string $campo,  [“parametros: …”])
+
maximum -» Valor maximo para insertar o actualizar
validates_numericality_of(string $campo)
+
too_long -» mensaje de alerta para el exceso de maximun
validates_email_in(string $campo)
+
minimum -» Valor minimo para insertar o actualizar
validates_uniqueness_of(string $campo)
 
validates_date_in(string $campo)
 
validates_format_of(string $campo, string $expresion_regular)
 
  
 +
too_short -» mensaje de alerta para el exceso de minimum
  
=== Parametros ===
+
in -» Rango del valor para insertar o actualizar
  
maximum -> Valor maximo para insertar o actualizar
 
too_long -> mensaje de alerta para el exceso de maximun
 
minimum -> Valor minimo para insertar o actualizar
 
too_short -> mensaje de alerta para el exceso de minimum
 
in -> Rango del valor para insertar o actualizar
 
  
  
 +
Callbacks
  
== Callbacks ==
+
before_create
 +
after_create
  
 +
before_save
 +
after_save
  
before_create
 
  
after_create
+
before_update  
before_save
+
after_update  
after_save
+
 
before_update
+
before_delete  
after_update
+
after_delete  
before_delete
+
 
after_delete
 
 
before_validation
 
before_validation
 +
 
after_validation
 
after_validation
before_validation_on_create
 
after_validation_on_create
 
before_validation_on_update
 
after_validation_on_update
 
  
  
 +
before_validation_on_create
 +
after_validation_on_create
 +
 +
before_validation_on_update
 +
after_validation_on_update
 +
 +
 +
Convenciones
 +
id -» Nombre de llave primaria
 +
tabla_id -» Nombre de llave foranea
 +
 +
campo_at -» Campo de tipo fecha fija
 +
campo_in -» Campo de tipo fecha actualizable
  
== Convenciones ==
 
id -> Nombre de llave primaria
 
tabla_id -> Nombre de llave foranea
 
campo_at -> Campo de tipo fecha fija
 
campo_in -> Campo de tipo fecha actualizable
 
  
  
== Asociaciones ==
+
Asociaciones  
  
belongs_to(string $relacion,  [“parametros: …”])
+
belongs_to(string $relacion,  [“parametros: …”])  
has_one(string $relacion,  [“parametros: …”])
+
has_one(string $relacion,  [“parametros: …”])  
has_many(string $relacion,  [“parametros: …”])
+
has_many(string $relacion,  [“parametros: …”])  
has_and_belongs_to_many(string $relacion,  [“parametros: …”])
+
has_and_belongs_to_many(string $relacion,  [“parametros: …”])  
  
 +
Parametros
 +
model -»Nombre del modelo
  
 +
fk -»Nombre del campo foraneo
  
=== Parametros ===
+
key -» Nombre del campo primario
  
model ->Nombre del modelo
+
through -» Nombre de la tabla relacional
fk ->Nombre del campo foraneo
 
key -> Nombre del campo primario
 
through -> Nombre de la tabla relacional
 

Revisión actual del 22:32 12 may 2010

Hoja de ayuda para la versión 1.0 beta1 (Spirit)

Recordemos que esta hoja de ayuda va para la version 1.0 beta1 Aqui definimos el orden del contenido para luego pasarlo a un PDF o PNG los colores y fuentes no importan, solo el que esten completos, buena sintaxis y en el orden adecuado

Chuleta.jpg


Aqui esta el contenido de la chuleta; usenlo para crear sus propias versiones :)


Clases Load::lib(string $nombre) Load::model(string $nombre) Load::models(array $nombres)

Flash::error(string $mensaje) Flash::success(string $mensaje) Flash::notice(string $mensaje) Flash::warning(string $mensaje)

Session::set(string $nombre, $valor) Session::get(string $nombre) Session::unset_data(string $nombre) Session::isset_data(string $nombre)


Upload::file_in_path(string $nombre, string $path, string $nuevo_nombre) Upload::file(string $nombre, string $nuevo_nombre) Upload::image(string $nombre, string $nuevo_nombre)


Filter


Add_filter($filter) Apply($var, [filters]) y apply_filter($var, [filters]) Get_instance()

aqui faltan mas y en la wiki tambien; tambien tengo dudas si los de abajo estan en la beta1


Filter::get(mixed $s, array $opciones) Filter::get_array($array, array $opciones) Filter::get_object($object, array $opciones)

Filtros addslashes alnum alpha date digits htmlentities htmlspecialchars int ipv4 lower md5 nl2br numeric stripslashes stripspace striptags trim upper


Paths APP APP_PATH CORE_PATH PUBLIC_PATH APP_CHARSET URL_PATH


Constante Descripción APP Nombre de la Aplicación APP_PATH ruta absoluta de la aplicación (/path/to/app/) CORE_PATH ruta absoluta del core (/path/to/core/) PUBLIC_PATH URL_PATH APP_CHARSET

Helpers

form_tag(string $action) text_field_tag($nombre) textarea_tag($nombre) password_field_tag($nombre) hidden_field_tag($name) checkbox_field_tag($nombre) radio_field_tag($nombre, $lista) date_field_tag($nombre) file_field_tag($nombre) upload_image_tag($nombre) select_tag($name, $lista) button_tag($caption) submit_image_tag($caption, $src) submit_tag($caption) end_form_tag()

img_tag(string $src) swf_tag(string $src) comillas($texto)

render_partial(string $nombre) link_to(string $url, string $texto)


javascript_include_tag($archivo_js) javascript_library_tag($archivo_js) stylesheet_link_tag($archivo_css, [use_variables: true])


Controller Metodos

render(string $view) post(array $valor) get(array $valor) request($valor) route_to([params: valor]) redirect(string $controlador, integer $segundos) cache_layout(integer $minutos) not_found(string $controller, string $action) set_response(string $tipo) is_alnum($valor) load_record($registro) is_numeric($valor)

has_post(string $nombre) //Verifica si existe una variable dentro del array $_POST has_get(string $nombre) //Verifica si existe una variable dentro del array $_GET has_request(string $nombre) //Verifica si existe una variable dentro del array $_REQUEST


set_persistent(string $nombre, $valor) //hace persistente valores para el controlador actual get_persistent(string $nombre) //Recupera el el valor persistente destroy_persistent(string $nombre) //destruye el valor persistente


Propiedades $action_name -» Nombre de la accion actual $controller_name -» Nnmbre del controller actual $template -» Nombre del template a usar $debug -» Activacion del modo Debug


Filtros before_filter() after_filter()


Models ACTIVE RECORD

Consultas

distinct([string $atributo_entidad], [“conditions: …], [“order: …”], [“limit: …“], [“columns: …”]) find_by_sql (string $sql) find_all_by_sql (string $sql) find_first([integer $id], [“conditions: …”], [“order: …”], [“limit: …], [“columns: …”]) find([integer $id], [“conditions: …”], [“order: …”], [“limit: …], [“columns: …”]) select_one(string $select_query) exists([“conditions: …”]) find_all_by(string $campo, string $valor) find_by_*campo*(string $valor) find_all_by_*campo*(string $valor)

sql (string $sql)


count(string $condicion) count_by_sql(string $sql) sum(string $campo, [“conditions: …”])


average(string $campo, [“conditions: …”]) maximum(string $campo, [“conditions: …”]) minimum(string $campo, [“conditions: …”])



create() update() update_all( [“conditions: …”]) save() create_from_request() save_from_request() delete(integer $id) delete_all()


Validaciones

validates_presence_of(string $campo) validates_length_of(string $campo, [“parametros: …”]) validates_numericality_of(string $campo) validates_email_in(string $campo) validates_uniqueness_of(string $campo) validates_date_in(string $campo) validates_format_of(string $campo, string $expresion_regular)

Parametros maximum -» Valor maximo para insertar o actualizar too_long -» mensaje de alerta para el exceso de maximun minimum -» Valor minimo para insertar o actualizar

too_short -» mensaje de alerta para el exceso de minimum

in -» Rango del valor para insertar o actualizar


Callbacks

before_create after_create

before_save after_save


before_update after_update

before_delete after_delete

before_validation

after_validation


before_validation_on_create after_validation_on_create

before_validation_on_update after_validation_on_update


Convenciones id -» Nombre de llave primaria tabla_id -» Nombre de llave foranea

campo_at -» Campo de tipo fecha fija campo_in -» Campo de tipo fecha actualizable


Asociaciones

belongs_to(string $relacion, [“parametros: …”]) has_one(string $relacion, [“parametros: …”]) has_many(string $relacion, [“parametros: …”]) has_and_belongs_to_many(string $relacion, [“parametros: …”])

Parametros model -»Nombre del modelo

fk -»Nombre del campo foraneo

key -» Nombre del campo primario

through -» Nombre de la tabla relacional