initphp / database Goto Github PK
View Code? Open in Web Editor NEWThis library uses PDO. It offers DBAL, Data Mapper, Query Builder and ORM.
License: MIT License
This library uses PDO. It offers DBAL, Data Mapper, Query Builder and ORM.
License: MIT License
Hi,
Why we have to use composer as apposed to putting php files in a folder and start using them?
Isn't this a simple php class? or people simply want to make things harder in order to impress others?
hi
i have a problem with insert arabic in my database it's showing "????" in database
i check every thing
table charset is utf8mb4_general_ci
\InitPHP\Database\Facade\DB::createImmutable([
'dsn' => "mysql:host={$database['host']};port={$database['port']};dbname={$database['db']};charset=utf8mb4",
'username' => $database['user'],
'password' => $database['pass'],
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'debug' => true, // boolean
]);
i check $_POST['username']; before insert and it's arabic
i check page meta is "utf-8"
i try insert arabic using phpmyadmin and all good
sorry for my poor english
any help please ?
Loglama; credentials içinde bir log değeri olarak;
critical()
metoduna SQL cümlesi hata iletisi ile birlikte verilir.use \InitPHP\Database\Facade\DB;
$data = [
'title' => 'New Title',
'order' => '1',
'content' => 'New Content',
];
$isUpdate = DB::from('post')
->where('id', 13)
->update($data);
/**
* This executes the following query.
*
* UPDATE post
* SET title = "New Title", content = "New Content"
* WHERE id = 13
*/
if ($isUpdate) {
// Success
} else {
$errors = DB::getError();
foreach ($errors as $errMsg) {
echo $errMsg;
}
}
Firstly thanks for nice library :D and please keep good updating of it
this code above will give error
Fatal error: Uncaught InitPHP\Database\Exceptions\SQLQueryExecuteException: SQLSTATE[42000]: Syntax error or access violation: 1064 You
have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = 1
the problem is column "order" is restracted in mysql and must escaped with ``
how to do that with update function ??
I noticed that the Result->toAssoc() function returns a single array when the result has 1 row. That is, the array returned is not an array of associative arrays. So it makes it inconsistent when looping over the values. For example.
DB::table('test')->where('name', 1)->get()->toAssoc(); // returns
// [ 'name' => 'test ]
// next
DB::table('test')->get()->toAssoc(); // returns
//[ [ 'name' => 'test'], ['name' => 'test2'], ... ]
how to use replace into with initPHP\Database library ?
example
$data = array(
array('id' => 1, 'name' => 'John'),
array('id' => 2, 'name' => 'Jane'),
// Add more data as needed
);
// Prepare the SQL statement
$sql = "REPLACE INTO your_table (id, name) VALUES (:id, :name)";
// Prepare the PDO statement
$stmt = $pdo->prepare($sql);
// Iterate through the data and execute the statement for each set of values
foreach ($data as $row) {
try {
$stmt->execute($row);
// Handle success or log if needed
} catch (PDOException $e) {
// Handle error or log if needed
echo "Error: " . $e->getMessage();
}
}
I see you have updated your library and many files have been removed!!
If I update the library in my project will there be any problem?
hi
how to show errors when $isUpdate is false ??
<?php
use \InitPHP\Database\Facade\DB;
$data = [
'title' => 'New Title',
'content' => 'New Content',
];
$isUpdate = DB::from('post')
->where('id', 13)
->update($data);
/**
* This executes the following query.
*
* UPDATE post
* SET title = "New Title", content = "New Content"
* WHERE id = 13
*/
if ($isUpdate) {
echo 'Success';
} else {
// show errors here
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.