CakePHP ?? ??
Sep 10, 2024 pm 05:25 PM??????? ???? ????? ?? TableRegistry ???? ???? ???? ???? ???. get() ???? ???? ??????? ????? ??? ? ????. get() ???? ?????? ???? ??? ??? ?????. ?? ? ? ????? ????? ?? ???? ???? ? ?????.
? ? ????? get() ???? ???? ?? ?? ???? ?? ????? ??? ???? ????. ???????? ???? ????? TableRegistry ???? ????? ???? delete ???? ?????.
?
?? ??? ?? config/routes.php ??? ?????.
config/routes.php
<?php use Cake\Http\Middleware\CsrfProtectionMiddleware; use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->registerMiddleware('csrf', new CsrfProtectionMiddleware([ 'httpOnly' => true, ])); $builder->applyMiddleware('csrf'); //$builder->connect('/pages',['controller'=>'Pages','action'=>'display', 'home']); $builder->connect('/users/delete', ['controller' => 'Users', 'action' => 'delete']); $builder->fallbacks(); });
src/Controller/UsersController.php?? UsersController.php ??? ?????. ???? ??? ?? ??? ?????.
src/controller/UsersController.php
<?php namespace App\Controller; use App\Controller\AppController; use Cake\ORM\TableRegistry; use Cake\Datasource\ConnectionManager; class UsersController extends AppController{ public function index(){ $users = TableRegistry::get('users'); $query = $users->find(); $this->set('results',$query); } public function delete($id){ $users_table = TableRegistry::get('users'); $users = $users_table->get($id); $users_table->delete($users); echo "User deleted successfully."; $this->setAction('index'); } } ?>
Users ???? ??? delete.ctp?? ? View
??? ????.src/???/Users/delete.ctp
src/Template? Users ????? ???? ?? ??? ?? ???? ?? ???? ??? index.ctp?? View??? ?????. . ?? ??? ?? ??? ?????.
src/Template/Users/index.ctp
<a href="add">Add User</a> <table> <tr> <td>ID</td> <td>Username</td> <td>Password</td> <td>Edit</td> <td>Delete</td> </tr> <?php foreach ($results as $row): echo "<tr><td>".$row->id."</td>"; echo "<td>".$row->username."</td>"; echo "<td>".$row->password."</td>"; echo "<td><a href='".$this->Url->build(["controller" => "Users","action" => "edit",$row->id])."'>Edit</a></td>"; echo "<td><a href='".$this->Url->build(["controller" => "Users","action" => "delete",$row->id])."'>Delete</a></td></tr>"; endforeach; ?> </table>
?? URL? ???? ?? ??? ???? ?? ??? ???? ??? ?????.
http://localhost:85/CakePHP/???
??
? URL? ?? ? ?? ??? ???? ??? ?? ??? ??? ? ?? ??? ?????.

??? ????? ?? ??? ?????.

? ??? CakePHP ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











STD :: Chrono? ?? ?? ??, ?? ?? ??, ?? ?? ? ?? ?? ? ?? ?? ??? ???? C?? ???? ??? ?????. 1. std :: chrono :: system_clock :: now ()? ???? ?? ??? ?? ? ??? ?? ??? ???? ?? ? ? ??? ??? ??? ???? ?? ?? ? ????. 2. std :: Chrono :: steady_clock? ???? ?? ??? ???? ?? ??? ???? duration_cast? ?? ?? ?, ? ? ?? ??? ??????. 3. ?? (time_point) ? ?? (??)? ?? ??? ? ? ??? ?? ??? ? ?? epoch (epoch)???? ???????.

toaccessenvironmentvariablesinphp, usegetenv () ?? $ _envsuperglobal.1.getenv ( 'var_name') retrievespescificvariable.2. $ _ en v [ 'var_name'] accessesvariablesifvariables_orderinphp.iniincludes "e".setvariablesviacliwithvar = valuephpscript.php, inapach

phphasthreecommentstyles : //, #forsingle-lineand/.../formulti-lline.usecommentstoexplainwhycodeexists, notwhatitdoes.marktodo/fixMeitemsandDisableCodeTemporlinlyDuingDeBugging.aVoidOver-commentingsimplOgic.writeCoCoCoCoCoConcomeCOCOCOCONCOCOCOCOCOCOCOCOCISE

?? ?? ?? ??? ?? ??? ??? : 1. ?? ?? ??? ??? ?? ?? ??? ???? ????? OB_START () ??? ???????. 2. ??? ???? ??? ?? ?? ??? ???? ?? ?? ?? ?? ?? ???????. 3. ?? ??? ?? ?? ? ?? ? ??? ?? ???? ???? ???? ?? ???????. 4. ?? ?? ?? ?? ??? ??? ??? ??? ???? ?? ???? ?? ? ? ????.

PHP?? ?????? ?? ??? ?? ?? ??? ?? ???? ??? ???? ?? ????. 1. MySQLI? ??? ?? ?? ??? ??? get_result () ? fetch_assoc ()? ?? ?? ??? ?? ? ????. 2. BIND_RESULT ()? ???? ??? ??? ??? ? ? ????. ??? ??? ?? ??? ???? ??? ???? ???? ????? ??? ?? ? ?? ??? ????. 3. PDO? ???? ?? Fetch (PDO :: Fetch_Assoc)? ?? ?? ??? ??? FetchAll ()? ???? ? ?? ?? ???? ?? ? ???? ?????? ???? ?? ??? ?????. ?? ?? ?? ?? ??, Execute () ??, ??? ?? ??? ? ?? ???? ????????.

PHP??? ??? ??? ???? ???? ?? ???? ????? ??? ??? ? ????. 1. strncmp ()? ???? ? ?? n ??? ??????. 0? ???? ??? ???? ??? ???? ????. 2. strpos ()? ???? ?? ??? 0?? ??????. stripos ()? ?? ?? ??? ???? ?? ??? ? ????. 3. ??? ?? ????? ?? startSwith () ?? str_starts_with () ??? ??? ? ? ????. ?? ? ???? ????? TRUE? ???? ???? ?? ??? ????? strncmp ()? ????? ? ?????? ?? ???????.

"undefinedIndex"??? ??? ? ?? ?? ??? ????. ??, ISSET ()? ???? ?? ?? ????? ???? ?? NULL? ??? ??????. ?? ?? ???? ????? ?????. ??, array_key_exists ()? ???? ?? ????? ?? ? ?????. ?? ?? ???? ?? ?? NULL ? ??? ?????. ????? ? ?? ???? ??????. (PHP7) ?? PHP ????? ???? ???? ???? ???? ?? ?? ??? ??????? ???? Extract ()??? ?? ????, ??? ?? ?? ??? ???? ????? ?? ??? ? ?????.

PHP ??? ???? ???? ???? ??? ??? ? 1. ??? ??? ?? ?? ???? ???? ?????. 2. PDO? ??? ?? ??? ?? ???? Array_Values? ???? ?? ???? ?? ? ? ????. 3. MySQLI? ??? ?? ?? ???? ???? ?? ??? ??????? ?? ? ?? ???? ???? ?????? ???????. 4. SQL ? ??? ?, ? ?? ?? ? ??? ??? ????? ??????. ???? ??? ??? ????. ?? Alflode ? Array_fill? ???? ?? ???? ?? ? ?? ?? ? ??? ?? ?? ??? ????? ??? ???? ?????.
