Concluído

PDO expert for exceptions

I am looking for a expert in pdo to help make my exceptions better. I have moved my website from sql to pdo and i have a few errors with query's i have difficulty identifying.

I do NOT want any errors fixing i hope to fix these myself i just need the errors documented better.

This is a example of my current exception log ([login to view URL])

Uncaught Exception: 2020-01-19 09:26:44 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'orange'>Shout Deleted:</font> Deleted by username</b>')' at line 1 in file /home/test/public_html/backend/[login to view URL] on line 32

As you can see the error says its the database class when actually the error is on [login to view URL] on line 19 i can fix this by changing

write_log("<b><font color='orange'>Shout Deleted:</font> Deleted by ".$CURUSER['username']."</b>");

to

write_log("<b><font color=orange>Shout Deleted:</font> Deleted by ".$CURUSER['username']."</b>");

If the exceptions pointed to the right file i could fix them and i dont want to change the [login to view URL] because that would mean changing all files - i just need exceptions pointing to right file instead of database.

I have been told on support forums this maybe impossible due to my [login to view URL] and the way i have done my queries

I am using a blunt singleton class this was the easiest way and i had 1000 queries so a global static suited me to make it quicker. I would prefer not to wrap every query in try/catch to identify exceptions. Is they any function that might help like backtrace or gettrace im a novice so maybe theres a better way any help would be very appreciated

[login to view URL]

<?php

define('DB_HOST', 'host');

define('DB_NAME', 'db');

define('DB_USER', 'user');

define('DB_PASS', 'pass');

define('DB_CHAR', 'utf8');

class DB

{

protected static $instance = null;

protected function __construct() {}

protected function __clone() {}

public static function instance()

{

if (self::$instance === null)

{

$opt = array(

PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,

PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,

PDO::ATTR_EMULATE_PREPARES => FALSE,

);

$dsn = 'mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset='.DB_CHAR;

self::$instance = new PDO($dsn, DB_USER, DB_PASS, $opt);

}

return self::$instance;

}

public static function __callStatic($method, $args)

{

return call_user_func_array(array(self::instance(), $method), $args);

}

public static function run($sql, $args = [])

{

if (!$args)

{

return self::instance()->query($sql);

}

$stmt = self::instance()->prepare($sql);

$stmt->execute($args);

return $stmt;

}

}

exception_handler

function handleUncaughtException($e){

// Show general page to public

header("Location: [login to view URL]");

// Construct the error string

$error = "Uncaught Exception: " . $message = date("Y-m-d H:i:s - ");

$error .= $e->getMessage() . " in file " . $e->getFile() . " on line " . $e->getLine() . "\n";

// Log details of error in a file

error_log($error, 3, "[login to view URL]");

}

// Register custom exception handler

set_exception_handler("handleUncaughtException");

example of query

$stmt = DB::run("SELECT word FROM censor ORDER BY word");

while ($row = $stmt->fetch())

Heres my github [login to view URL]

You can see changes from sql to pdo here [login to view URL]

I would like know how this would be approached before i award the project i have nearly finished my project so do not wish to make big changes or fix any errors i just need exceptions to point to the right file

i have attached the [login to view URL]

Habilidades: PHP

Veja mais: zend_pdf utf8, php design expert, streaming video server expert, expert linux live, google earth expert, attached php file, paypal expert money, as2 pass variable function, php security expert, wiki expert, magento shopping cart expert, php pass arguments construct, pass expert rating tests, need help pass expert rating photoshop test, pdo expert, digital access pass expert

Acerca do Empregador:
( 3 comentários ) leeds, United Kingdom

ID do Projeto: #23456555

Concedido a:

justTry

Hi! You sound like being developer yourself, so should be well aware that asking for us to explain what the approach would be, especially in this kind of jobs, means to give you the solution right away. So for you t Mais

£18 GBP em 0 dias
(162 Comentários)
6.0

6 freelancers estão ofertando em média £17 para esse trabalho

purplemaestro

Hi my name is Muhammad Hassan. I have high level expertise in handling PDO exception in a professional way. I can start right now and can do the work on time. Please share the work details so that I can start working o Mais

£20 GBP em 1 dia
(20 Comentários)
4.4
shashilal

I am indivisual software developer having 7 + years exp in Php,cake,codiegnator and wp,I have completed many web based project in all areas like edu,real estate,insurance,ecommerce. etc.

£15 GBP in 3 dias
(14 Comentários)
3.0
AuspCluster

Hi, Hope you are doing great, We are group of experts designers and developers. Allow us to work for you, We can give you best possible work in minimum time. Kindly ping me for further discussion. Check our Portfolio Mais

£10 GBP em 1 dia
(7 Comentários)
2.0
polinatolbuhina3

Hi there. Thanks for posting:) I am ready for you anytime. Looking forward to hearing from you. Regards

£20 GBP in 7 dias
(3 Comentários)
1.5
nivekaa

Hello There. I have read the description, I have great experience doing similar jobs related to these skills SQL, MYSQL PHP/PDO. Please start the chat so we can have detailed discussion. Thanks.

£20 GBP em 1 dia
(0 Comentários)
0.0