本文整理汇总了PHP中ORM::as_array方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::as_array方法的具体用法?PHP ORM::as_array怎么用?PHP ORM::as_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::as_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: as_array
/**
* Returns an array of all the '_col' members. The keys will be the name
* of the member with the '_col' chopped off the end.
*
* @todo update to work with $this->_orm
* @return array
*/
public function as_array()
{
if ($this->_orm) {
$data = $this->_orm->as_array();
} else {
$data = array();
foreach ($this as $key => $val) {
if (substr($key, -4) == '_col' && $val) {
$data[substr($key, 0, -4)] = $val;
}
}
}
return $data;
}
示例2: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('type', 'required', 'length[0,255]')->add_rules('version', 'required', 'length[0,255]')->add_rules('major_version', 'length[0,255]')->add_rules('minor_version', 'length[0,255]')->add_rules('agent_detail', 'required', 'length[0,255]')->add_rules('ip', 'required', 'numeric')->add_rules('quantity', 'numeric')->add_rules('date_add', 'required', 'length[1,255]')->add_rules('date_upd', 'required', 'length[1,255]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例3: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('name', 'required', 'length[1,200]')->add_rules('resource', 'required', 'length[1,200]')->add_rules('parent_id', 'numeric')->add_rules('order', 'numeric');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例4: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save[Optional] the record when validation succeeds
* @param string error info
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('name', 'required', 'length[1,250]')->add_rules('username', 'required', 'length[1,250]')->add_rules('email', 'required', 'length[1,320]')->add_rules('password', 'required', 'length[1,100]')->add_rules('address', 'length[0,255]')->add_rules('role_id', 'numeric')->add_rules('site_num', 'required', 'numeric')->add_rules('contact_name', 'length[0,250]')->add_rules('phone', 'length[0,250]')->add_rules('mobile_phone', 'length[0,100]')->add_rules('postcode', 'length[0,20]')->add_rules('fax', 'length[0,255]')->add_rules('country', 'length[0,255]')->add_rules('province', 'length[0,255]')->add_rules('city', 'length[0,255]')->add_rules('township', 'length[0,255]')->add_rules('is_admin', 'digit')->add_rules('type', 'numeric')->add_rules('active', 'numeric');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例5: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('name', 'required', 'length[1,255]')->add_rules('title', 'required', 'length[1,255]')->add_rules('content', 'required', 'length[1,65536]')->add_rules('mail_category_id', 'required', 'numeric');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例6: validate
public function validate(array &$array, $save = FALSE, &$errors = '')
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('order_id', 'required', 'numeric')->add_rules('uid', 'required', 'numeric')->add_rules('type', 'required', 'numeric')->add_rules('price', 'required', 'numeric')->add_rules('model', 'length[0,255]')->add_rules('model_name', 'length[0,255]')->add_rules('preview', 'length[0,255]')->add_rules('preview_name', 'length[0,255]')->add_rules('size', 'length[0,100]')->add_rules('material', 'length[0,100]')->add_rules('color', 'length[0,100]')->add_rules('precision', 'length[0,100]')->add_rules('quantity', 'numeric')->add_rules('draft', 'length[0,255]')->add_rules('message', 'length[0,65535]')->add_rules('front_money', 'required', 'numeric')->add_rules('status', 'required', 'numeric');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例7: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('name', 'required', 'length[1,200]')->add_rules('domain', 'required', 'length[0,320]')->add_rules('site_title', 'length[0,250]')->add_rules('logo', 'length[0,250]')->add_rules('site_email', 'required', 'length[0,320]')->add_rules('theme_id', 'required', 'numeric')->add_rules('active', 'numeric')->add_rules('wholesale', 'numeric')->add_rules('is_wholesale', 'numeric')->add_rules('https', 'numeric')->add_rules('memo', 'length[0,255]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例8: validate
public function validate(array &$array, $save = FALSE, &$errors = '')
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('username', 'required', 'length[0,20]')->add_rules('passwd', 'required', 'length[0,50]')->add_rules('email', 'required', 'length[0,100]')->add_rules('mobile', 'length[0,20]')->add_rules('name', 'length[0,10]')->add_rules('avatar', 'length[0,200]')->add_rules('tk', 'required', 'length[0,32]')->add_rules('lastlogin_time', 'required', 'length[0,200]')->add_rules('status', 'required', 'numeric');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例9: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('site_id', 'required', 'numeric')->add_rules('parent_id', 'numeric')->add_rules('sub_folder_ids', 'length[0,1024]')->add_rules('name', 'required', 'length[1,255]')->add_rules('level_depth', 'required', 'numeric')->add_rules('date_add', 'required', 'length[1,255]')->add_rules('date_upd', 'required', 'length[1,255]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例10: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('site_id', 'required', 'numeric')->add_rules('kc_folder_id', 'required', 'numeric')->add_rules('attach_id', 'required', 'length[1,50]')->add_rules('image_type', 'length[0,25]')->add_rules('image_size', 'required', 'numeric')->add_rules('image_name', 'required', 'length[1,255]')->add_rules('image_mime', 'length[0,100]')->add_rules('date_add', 'required', 'length[1,255]')->add_rules('date_upd', 'required', 'length[1,255]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
return FALSE;
}
}
示例11: validate
/**
* Validates and optionally saves a new delivery category from an array.
*
* @param array value to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('name', 'required', 'length[1,255]')->add_rules('ename', 'required', 'length[1,255]')->add_rules('description', 'length[1,1000]')->add_rules('edescription', 'length[1,1000]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
log::write('form_error', $errors, __FILE__, __LINE__);
return FALSE;
}
}
示例12: validate
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('status', 'numeric')->add_rules('manager_id', 'numeric')->add_rules('user_log_type', 'numeric')->add_rules('ip', 'length[0,255]')->add_rules('method', 'length[0,255]')->add_rules('memo', 'length[0,512]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
log::write('form_error', $errors, __FILE__, __LINE__);
return FALSE;
}
}
示例13: validate
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array &$array, $save = FALSE, &$errors)
{
$fields = parent::as_array();
$array = array_merge($fields, $array);
$array = Validation::factory($array)->pre_filter('trim')->add_rules('host', 'required', 'length[0,255]')->add_rules('port', 'required', 'numeric')->add_rules('username', 'required', 'length[0,255]')->add_rules('password', 'required', 'length[0,255]');
if (parent::validate($array, $save)) {
return TRUE;
} else {
$errors = $array->errors();
log::write('Smtp_queue_form_error', $errors, __FILE__, __LINE__);
return FALSE;
}
}
示例14: as_map
/**
* Does the same as as_array
* but also load the ids of has_many ans has_many_though relations
* Careful: this does extra queries!
* @return type
*/
public function as_map()
{
$map = parent::as_array();
foreach ($this->has_many() as $key => $data) {
$items = $this->{$key}->find_all();
$ids = array();
foreach ($items as $item) {
$ids[] = $item->id;
}
$map[$key] = $ids;
}
return $map;
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:19,代码来源:Base.php
示例15: _setDataFromObject
private function _setDataFromObject(ORM $dataObject)
{
$data = $dataObject->as_array();
foreach ($data as $key => $value) {
if (array_key_exists($key, $this->_dataOptional)) {
$this->_dataOptional[$key] = $value;
}
if (array_key_exists($key, $this->_dataRequired)) {
$this->_dataRequired[$key] = $value;
}
}
}