1. Go to this page and download the library: Download cakephp/database library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cakephp / database example snippets
use Cake\Database\Connection;
use Cake\Database\Driver\Mysql;
$driver = new Mysql([
'database' => 'test',
'username' => 'root',
'password' => 'secret'
]);
$connection = new Connection([
'driver' => $driver
]);
use Cake\Database\Connection;
$connection = new Connection([
'driver' => Cake\Database\Driver\Sqlite::class,
'database' => '/path/to/file.db'
]);
$query->select(['id', 'title', 'body']);
// Results in SELECT id AS pk, title AS aliased_title, body ...
$query->select(['pk' => 'id', 'aliased_title' => 'title', 'body']);
// Use a closure
$query->select(function ($query) {
return ['id', 'title', 'body'];
});
// WHERE id = 1
$query->where(['id' => 1]);
// WHERE id > 2
$query->where(['id >' => 1]);
// Iterate the query
foreach ($query as $row) {
// Do stuff.
}
// Get the statement and fetch all results
$results = $query->execute()->fetchAll('assoc');
sql
UPDATE articles SET title = 'New Title' WHERE created >= '2014-10-10 00:00:00' AND created < '2014-10-13 00:00:00';
sql
SELECT * FROM articles
WHERE
author_id = 2
AND published = 1
AND spam != 1
AND view_count > 10
sql
SELECT *
FROM articles
WHERE
NOT (author_id = 2 OR author_id = 5)
AND view_count <= 10
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.