本文整理汇总了PHP中Crud类的典型用法代码示例。如果您正苦于以下问题:PHP Crud类的具体用法?PHP Crud怎么用?PHP Crud使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Crud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
function authenticate()
{
if (!empty($_POST['username']) && !empty($_POST['password'] != '')) {
$username = $_POST['username'];
$password = $_POST['password'];
// Load the CRUD
require ROOT . '/justit-php-test/models/crud.php';
$crud_login = new Crud();
if ($crud_login->login($username, md5($password))) {
// Set sessions
$_SESSION['is_logged_in'] = TRUE;
// redirect to users
header('Location: ' . global_url() . 'users');
die;
} else {
echo 'Sorry login details are wrong';
// Set error return to login page
$this->index();
}
} else {
// Return back to the login
$this->error_message = "Please fill out the form";
$this->index();
}
}
示例2: primeiroLogin
public function primeiroLogin()
{
$pL = new Crud();
$pL->setTabela("users");
$result = $pL->consultar(array("id", "nome", "email"), "id = {$this->idInserido}");
$_SESSION['dehbora']['user'] = $result->fetch(PDO::FETCH_ASSOC);
}
示例3: insert
public function insert()
{
$params = Param::params();
$crud = new Crud();
$crud->insertQuestion($params);
$params['q_id'] = $crud->getInsertedId();
$crud->insertAnswer($params);
$this->render('index');
}
示例4: actionCreate
public function actionCreate()
{
$model = new Crud();
$form = new Form('codegen.CrudForm', $model);
if ($form->submitted() && $model->validate()) {
Yii::import('codegen.controllers.FormAdminController');
FormAdminController::generateAndSaveForm($model->class);
$params = $model->attributes;
$params['module'] = AppManager::getModelModule($model->class);
$controllers_path = 'codegen.views.templates.crud.controllers';
$controllers_files = glob(Yii::getPathOfAlias($controllers_path) . DS . '*');
foreach ($controllers_files as $controller_file) {
$file_name = pathinfo($controller_file, PATHINFO_FILENAME);
$code = $this->renderPartial($controllers_path . '.' . $file_name, $params, true);
$file_name = $model->class . $file_name . '.php';
$dir = MODULES_PATH . $params['module'] . DS . 'controllers' . DS;
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
chmod($dir, 0777);
}
$file_path = $dir . $file_name;
file_put_contents($file_path, $code);
chmod($file_path, 0777);
}
$views_path = 'codegen.views.templates.crud.views';
$views_files = glob(Yii::getPathOfAlias($views_path) . DS . '*' . DS . '*');
foreach ($views_files as $view_file) {
$view_file = str_replace(Yii::getPathOfAlias($views_path), '', $view_file);
$file_name = pathinfo($view_file, PATHINFO_BASENAME);
$file_code = $this->renderPartial($views_path . str_replace(array(DS, '.php'), array('.', ''), $view_file), $params, true);
$view_file_path = MODULES_PATH . $params['module'] . DS . 'views' . $view_file;
$view_file_dir = pathinfo($view_file_path, PATHINFO_DIRNAME);
$child_dir = pathinfo($view_file_dir, PATHINFO_FILENAME);
if ($child_dir == 'client') {
$view_file_dir = str_replace('client', lcfirst($model->class), $view_file_dir);
} else {
if ($child_dir == 'admin') {
$view_file_dir = str_replace('admin', lcfirst($model->class) . 'Admin', $view_file_dir);
}
}
if (!is_dir($view_file_dir)) {
mkdir($view_file_dir, 0777, true);
chmod($view_file_dir, 0777);
}
$file_path = $view_file_dir . DS . $file_name;
file_put_contents($file_path, $file_code);
chmod($file_path, 0777);
}
$msg = "Добавьте в метод adminMenu() в файле " . ucfirst($params['module']) . "Module.php<br/>\r\n 'Управление {$params['instrumental']}' => Yii::app()->createUrl('/{$params['module']}/" . lcfirst($params['class']) . "Admin/manage'), <br/>\r\n 'Создать {$params['accusative']}' => Yii::app()->createUrl(''/{$params['module']}/" . lcfirst($params['class']) . "Admin/create'),";
Yii::app()->user->setFlash(Controller::MSG_SUCCESS, 'CRUD создан!');
Yii::app()->user->setFlash(Controller::MSG_INFO, $msg);
$this->redirect($_SERVER['REQUEST_URI']);
}
$this->render('create', array('form' => $form));
}
示例5: testCrud
public function testCrud()
{
$c = new Crud();
$c->addSubject(array('data' => array(array('id' => '123', 'title' => 'shirt', 'images' => array('https://upload.wikimedia.org/wikipedia/commons/8/8c/Polo_Shirt_Basic_Pattern.png'), 'thumbnails' => array('https://upload.wikimedia.org/wikipedia/commons/8/8c/Polo_Shirt_Basic_Pattern.png')))));
$r = $this->engine->upload($c);
$this->assertEquals($r->status, 200);
$r = $this->engine->update($c);
$this->assertEquals($r->status, 200);
$r = $this->engine->delete($c);
$this->assertEquals($r->status, 200);
}
示例6: Email
public function Email($codeIgniterDb = null)
{
parent::Crud($codeIgniterDb);
$this->data = array('ID' => '', 'sender' => '', 'receiver' => '', 'subject' => '', 'message' => '', 'error' => '', 'status' => '');
$this->table = 'emails';
$this->key = 'ID';
}
示例7: Offer
public function Offer($codeIgniterDb = null)
{
parent::Crud($codeIgniterDb);
$this->data = array('id' => '', 'question' => '', 'value' => '', 'count' => '');
$this->table = 'offers';
$this->key = 'script';
}
示例8: Activator
public function Activator($codeIgniterDB = null)
{
parent::Crud($codeIgniterDB);
$this->table = 'activations';
$this->data = array('email' => '', 'activationKey' => '');
$this->key = 'activationKey';
}
示例9: Assessment
/**
* Marks relate to scripts on a one-to-one basis, and therefore they share
* a primary key: the ID field of script, thus script.ID = mark.script
*
* @param unknown_type $codeIgniterDb
* @return Mark
*/
public function Assessment($codeIgniterDb = null)
{
parent::Crud($codeIgniterDb);
$this->data = array('script' => '', 'marker' => '', 'markData' => '', 'status' => '', 'targets' => '', 'generalComment' => '');
$this->table = 'assessments';
$this->key = 'marker';
}
示例10: AssessmentFix
public function AssessmentFix($codeIgniterDb = null)
{
parent::Crud($codeIgniterDb);
$this->data = array('email' => '', 'hadProblem' => '', 'paid' => '');
$this->table = 'assessmentFix';
$this->key = 'email';
}
示例11: get
public function get($field)
{
if ($field === 'marks') {
return unserialize($this->data['marks']);
}
return Crud::get($field);
}
示例12: Ticket
public function Ticket($codeIgniterDb = null)
{
parent::Crud($codeIgniterDb);
$this->data = array('ID' => '', 'email' => '', 'subject' => '', 'message' => '');
$this->table = 'tickets';
$this->key = 'ID';
}
示例13: get
function get($key)
{
if ($key === 'scripts') {
return unserialize($this->data['scripts']);
}
return Crud::get($key);
}
示例14: run
public static function run($obj, $webClass)
{
if ($obj instanceof Model) {
$cmd = isset($_GET['cmd']) ? addslashes($_GET['cmd']) : 'read';
if ($cmd == "edit") {
Crud::createForm($obj, $webClass);
die;
}
if ($cmd == "add") {
//Crud::createForm($obj,$webClass);
$json = Crud::addPrecon($obj);
die(json_encode($json));
}
if ($cmd == "delete") {
$json['bool'] = 1;
$id = isset($_POST['id']) ? addslashes($_POST['id']) : '';
$json['bool'] = $obj->delete($id);
die(json_encode($json));
}
if ($cmd == "ws") {
Crud::workWebService($obj, $webClass);
die;
}
Crud::read($obj, $webClass);
} else {
die('Crud hanya bisa dipakai dengan object Crud');
}
}
示例15: Referral
function Referral($codeIgniterDB = null)
{
parent::Crud($codeIgniterDB);
$this->data = array('user' => '', 'referee' => '', 'ipRequested' => '', 'paypalRef' => '');
$this->table = 'referrals';
$this->key = 'referee';
}