Posts

php - Exception Catch and CallHook -

i'm using callhook execute classes , methods in mvc framework. no add error-handling php exception function. i'm wondering best place execute catch command. request can (of course) lead execution of multiple classes. throughout system exceptions made. (example mentioned below). function callhook() { global $urlarray; //define controllers if (strlen(strstr($urlarray[0],'popup_'))>0) { $controller = substr($urlarray[0], 6); } else { $controller = $urlarray[0]; } $querystring[] = $urlarray[1]; $urlaction = $urlarray[2]; if(!isset($controller) && empty($controller)){ $controller = 'home';} if(!isset($urlaction) || empty($urlaction)){$action = 'view';}else{$action = $urlaction;} $controllername = str_replace('-','', $controller); $controller = ucwords($controller); $model = rtrim($controller, 's'); $controller .= 'controller'; ...

oracle - patient table database design -

i have 2 tables patient , doctor: create table "patient" ( "patient_id" number not null enable, "patient_name" varchar2(40), "age" number, "sex" varchar2(12), "place" varchar2(40), "phone_number" number, "doctor_id" number, "registration_date" date, constraint "patient_pk" primary key ("patient_id") enable, constraint "doctor_id" foreign key ("doctor_id") references "doctor" ("doctor_id") enable ) create table "doctor" ( "doctor_id" number not null enable, "doctor_name" varchar2(40) not null enable, "place" varchar2(40), "phone_number" number, constraint "doctor_pk" primary key ("doctor_id") enable ) a patient can visit doctor several times (different doctors also), have insert values ...

datetime - Loop through file timestamps, and if it equals to today's date, copy file -

good day all i have bunch of sql files in folder. loop through each file , timestamp of file. if timestamp mathes current date, want copy file new location. here directory structure of files: c:\mfa\mfa_timestamp\mfa_timestamp.sql and example of file be: c:\mfa\mfa_20131008\mfa_20131008.sql so here code have far, not right... set currentdate=%date% /r c:\mfa\ %%g in (*.sql) set %%g=%file% %%f in (%file%) set filedatetime=%%~tf if %filedatetime:~0, 10% == %currentdate% goto same goto notsame :same copy %file% c:\newlocation goto next :notsame goto end :next any suggestions on doing wrong here? thanks @echo off setlocal enableextensions enabledelayedexpansion set "currentdate=%date:~0,10%" %%g in ("c:\mfa\*.sql") ( set "filedate=%%~tg" set "filedate=!filedate:~0,10!" if "!filedate!"=="%currentdate%" ( copy "%%~fg" "c:\newlocation" ) )...

database - INSERT vs UPDATE: MySQL, 7 million rows -

for opting is not programming question, have 1) code, 2) amount of algorithms of comparing data each row in option #1. i not asking how queries or how database should setup . i have run bit of pickle. have database follows google gtfs specs , writing automatic update program service database. the database gets overhaul once every 3 months. table least amount of rows consists of between 1-10 rows , largest table contains 7 million rows. rest have between 10 000 , 80 000. the files program download .txt files translate in table. in other words: stops.txt = database.stops. database innodb type. i have come 2 solutions. 1) every row id in several .txt documents compared in database, if nothing has changed nothing, if has changed, update. 2) insert downloaded files own tables (basically mirroring live tables) , switch table names. example: database.stop_new , database.stop switch names. another twist: overhaul done @ date defined in 1 of .txt files, means done saturday ...

python - How to fill a numpy array with a gradient with a vectorized code? -

Image
two numpy arrays have filled follow: [0 1 2] [0 1 2] [0 1 2] [0 1 2] [0 1 2]] [[0 0 0] [1 1 1] [2 2 2] [3 3 3] [4 4 4]] or a first idea was: ax=np.zeros((5,3),np.int16) ay=np.zeros((5,3),np.int16) j in range(0,3): in range(0,5): ax[i,j]=j#filling ax x=col ay[i,j]=i#filling ay y values y=li a second idea was: bx = np.zeros((5,3),np.int16) = np.zeros((5,3),np.int16) j in range(3): bx[:,j]=j in range(5): by[i,:]=i i sure there's better way, one? jp i think using numpy.tile might better: in [422]: np.tile((0,1,2), (5,1)) out[422]: array([[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]]) in [473]: tile(arange(5)[:,none], 3) out[473]: array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) time efficiency: for small matrix of shape (5,3), for-loop faster: in [490]: timeit np.tile((0,1,2), (5,1)) 10000 loops, best of 3: 38.3 per loop in [491]...

android - How to assign wrap_content as height to dynamically loaded gridview -

i loading gridview dynamically buttons. using scrollview, if assign wrap_content height gridview buttons not displayed. dont want assign static height gridview. code using: <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:paddingleft="5dip" android:paddingright="5dip" > <gridview android:id="@+id/gridviewtable" android:layout_width="fill_parent" android:layout_height=wrap_content" android:horizo...

php - Sending serialized form to database -

i'm trying send serialized form database. i'm doing because each form can have different number of user-created input fields , wanted simple way store forms same way. question when serialize form, use jquery attach hidden input field, , send the form , other information database, rest of information reaching database still have blank in serialized form is. if point out went wrong and/or explain how should done i'd grateful! thank much! here how i'm sending data database: $orderdate = mysql_prep($_post["orderdate"]); $ordername = mysql_prep($_post["ordername"]); $formserialized = mysql_prep($_post["formserialized"]); $query = "insert test (orderdate, ordername, orderserialized) values ('{$orderdate}', '{$ordername}', '{$orderserialized}')"; $result = mysqli_query($connection, $query); here hidden field trying attach serialized form to: <input type="hi...