/** * dbh_do_bind() - Execute a (possibly write access) SQL query with bound parameters * * @param string $sql The SQL query to run * @param mixed $params this can either be called passing an array of bind params, or just by passing the bind params as args after the SQL arg * @return PDOStatement */ function dbh_do_bind($sql) { $use_dbh = $this->dbh(); if (ORM_SQL_PROFILE) { START_TIMER('dbh_do_bind'); } $bind_params = array_slice(func_get_args(), 1); ### Allow params passed in an array or as args if (is_a($bind_params[count($bind_params) - 1], 'PDO') || is_a($bind_params[count($bind_params) - 1], 'PhoneyPDO')) { $use_dbh = array_pop($bind_params); } if (count($bind_params) == 1 && is_array(array_shift(array_values($bind_params)))) { $bind_params = array_shift(array_values($bind_params)); } $this->reverse_t_bools($bind_params); if (ORM_SQL_DEBUG || ORM_SQL_WRITE_DEBUG) { bug($sql, $bind_params); } $GLOBALS['ORM_SQL_LOG'][] = array(microtime(true), $sql, $bind_params); try { $sth = $use_dbh->prepare($sql); $rv = $sth->execute($bind_params); } catch (PDOException $e) { trace_dump(); $err_msg = 'There was an error running a SQL statement, [' . $sql . '] with (' . join(',', $bind_params) . '): ' . $e->getMessage() . ' in ' . trace_blame_line(); if (strlen($err_msg) > 1024) { bug($err_msg, $sql, $bind_params, $e->getMessage()); $sql = substr($sql, 0, 1020 + strlen($sql) - strlen($err_msg)) . '...'; } trigger_error('There was an error running a SQL statement, [' . $sql . '] with (' . join(',', $bind_params) . '): ' . $e->getMessage() . ' in ' . trace_blame_line(), E_USER_ERROR); return false; } if (ORM_SQL_PROFILE) { END_TIMER('dbh_do_bind'); } return $rv; }
function call_remote($sub, $params) { trace_dump(); return trigger_error("Couldn't locate the project directory: " . $this->config_swap($this->project_base) . " ...", E_USER_ERROR); ### $sub = preg_replace('/^.+::/','',$sub); ### ### $url = "https://admin.beta.project.org/project_manager/"; ### if ( $_SERVER['REMOTE_USER'] ) $url = "https://*****:*****@admin.beta.project.org/project_manager/"; ### ### $params = array( 'action' => 'remote_call', ### 'remote_call' => $sub, ### 'params' => urlencode( nfreeze( $params ) ), ### 'wantarray' => (wantarray ? true : false), ### ); ### # $agent = LWP::UserAgent->new; ### $response = $agent->post($url, $params); ### ### list($frozen) = preg_match('/\|=====\|(.+)\|=====\|/', ($response->content, $m)); ### $response_obj; ### if ( $frozen ) { ### $response_obj = thaw(urldecode($frozen)); ### if ( ! ref($response_obj) ) { ### BUG ["Not a ref", $frozen, $response_obj]; ### return trigger_error("Not a ref : ", E_USER_ERROR). $response->content; ### } ### } ### else { ### BUG ["Bad Response", $response->content]; ### return trigger_error("Bad Response : ", E_USER_ERROR). $response->content; ### } ### ### return( wantarray && UNIVERSAL::isa($response_obj, 'ARRAY') ### ? (@[$response_obj]) ### : $$response_obj ### ); }