本文整理汇总了PHP中M::cr方法的典型用法代码示例。如果您正苦于以下问题:PHP M::cr方法的具体用法?PHP M::cr怎么用?PHP M::cr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类M
的用法示例。
在下文中一共展示了M::cr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
static function getData($id)
{
PDOSql::$pdobj = pdoConnect();
$d = PDOSql::select("SELECT name, bg_image, subtitle FROM users WHERE id = ?", array($id));
if (count($d) > 0) {
$data['name'] = $d[0]['name'];
$data['bg_image'] = $d[0]['bg_image'];
$data['subtitle'] = $d[0]['subtitle'];
return M::cr(true, $data);
} else {
return M::cr(false, array('user' => array()), 'No se encontraron datos del usuario');
}
}
示例2: up2Web
public static function up2Web($img)
{
$msg = array();
$fname = self::name(DATAROOT, 'up_', pathinfo($img['name']));
$valid = self::validate($img, $fname);
if (!$valid->success) {
return M::cr(false, array(), $valid->msg);
}
// final move
if (!move_uploaded_file($img['tmp_name'], DATAROOT . $fname)) {
$msg[] = 'Failed to move uploaded file ' . $img['tmp_name'] . ' to ' . $fname;
}
// Check if $uploadOk is set to 0 by an error
if (count($msg) > 0) {
return M::cr(false, array(), implode(',', $msg));
} else {
return M::cr(true, array($fname));
}
}
示例3: edit
public static function edit($data)
{
$p = array('title' => array('required' => true, 'type' => 'string', 'maxlength' => 140, 'label' => 'Titulo'), 'text' => array('required' => true, 'type' => 'string', 'label' => 'Texto'), 'image' => array('required' => false, 'type' => 'thumbnail', 'label' => 'Imagen'), 'tags' => array('required' => false, 'type' => 'string', 'label' => 'Tags'));
$v = new Validator();
$response = $v->validate($data, $p);
if (!$response['success']) {
return M::cr(false, $data, $response['msg']);
}
PDOSql::$pdobj = pdoConnect();
if (isset($_FILES['image']['name'])) {
$response = File::up2Web($_FILES['image']);
if ($response->success) {
// remove old image...
if (isset($data['old_image'])) {
File::unlinkWeb($data['old_image']);
}
$image = $response->data[0];
} else {
return M::cr(false, $data, $response->msg);
}
} else {
$image = '';
}
$params = array($data['title'], $data['text'], $image, $data['tags'], $data['id'], $_SESSION['userNAME']);
$where = array(' id = ?', 'author = ?');
$query = "UPDATE entries SET title = ?, text = ?, image = ?, tags = ? {%WHERE%}";
PDOSql::update($query, $params, $where);
return M::cr(true, array(), 'Se han actualizado los datos correctamente');
}